Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    115
    Thanks
    2
    Thanked 10 Times in 10 Posts

    What Can Perl Do That PHP Can't?

    I'm considering learning some Perl to help round out my web development and programming skills. To me, it seems like it's kind of like a middle ground between C, PHP, and shell scripting...I could be way off though. Anyways, I heard Perl makes a good "duct-tape" language. What can Perl do that can't be easily done with other languages?

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Well Perl can be used equally well for writing non-web scripts as it can be used on the web. So the bonus is that you can use one language for both activities.

    I like using Perl on the web because of it's CGI library. You can write the entire page in Perl using function calls for all the HTML elements. The advantage is the code is cleaner (no mix of static HTML and code that can happen in say PHP) and all your code isn't tied to a specific doctype. Right now I believe the CGI library generates XHTML 1.0 Strict. However in a couple years if they change to HTML 5, all you would have to do is update the CGI library on the server and your site is then done in HTML 5.
    OracleGuy

  • #3
    Super Moderator
    Join Date
    May 2005
    Location
    Southern tip of Silicon Valley
    Posts
    2,874
    Thanks
    2
    Thanked 164 Times in 159 Posts
    I think a better question would be: "I want to accomplish xx task, between Perl and PHP which language would be best?".

    Both languages have their strengths and weaknesses. Perl is still the stronger and more developed language. but PHP has grown a lot over the last several years. If you ask a Perl programmer, like me, you will be told that Perl is better, however, if you ask a PHP programmer you will be told that PHP is better.

    To answer your question..."What Can Perl Do That PHP Can't?"... you first need to be equally knowlageble and competent in both, which I am not. I have written a couple PHP web sites at work, but I hated every minute of it.

  • #4
    Regular Coder
    Join Date
    Aug 2004
    Posts
    368
    Thanks
    10
    Thanked 4 Times in 4 Posts
    I asked for a review of PHP in the PHP forum awhile back, and I believe my post was deleted. Nice to know we're more open minded over here.
    I have tried both PHP and Perl, and I find that Perl is much much simpler, and definitely a lot more fun.
    I am no expert on either language. Just my opinion.

  • #5
    Regular Coder
    Join Date
    Oct 2004
    Posts
    168
    Thanks
    0
    Thanked 5 Times in 5 Posts
    PHP was born out of a few Perl scripts. That said, in my experience each language is capable of doing what the other can do, it's just that one language's method of achieving a particular solution can be faster performing / more reliable / easier to implement / philosophically preferable / more scalable / more flexible / better supported / more secure / shorter ;-) etc than the other's.
    So it just comes down to choosing the right tool for the job in hand.

    PS
    Perl is more poetic than PHP, and inherently more beautiful.

  • #6
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    254
    Thanks
    1
    Thanked 63 Times in 63 Posts
    Quote Originally Posted by oracleguy View Post
    Well Perl can be used equally well for writing non-web scripts as it can be used on the web. So the bonus is that you can use one language for both activities.
    PHP can be used for non-web scripts as well (PHP CLI) and if I'm not mistaken, it's been a "default" feature since 5.0 (maybe earlier) albeit far less known and far less used.

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Posts
    368
    Thanks
    10
    Thanked 4 Times in 4 Posts
    Quote Originally Posted by shadowmaniac View Post
    PHP can be used for non-web scripts as well (PHP CLI) and if I'm not mistaken, it's been a "default" feature since 5.0 (maybe earlier) albeit far less known and far less used.
    That's interesting. Wonder why that never caught on like the web interface. I guess probably because PHP was introduced as the perfect marriage to MySql?

  • #8
    Regular Coder cs_student's Avatar
    Join Date
    Oct 2009
    Location
    ~/
    Posts
    195
    Thanks
    2
    Thanked 22 Times in 22 Posts
    OP, if you want something which is a middleground for both web-development and general programming, you might want to check out python. You can use it as a server side scripting language for web pages. You can also use it to make graphical (as well as command line) applications on the desktop. It also has a very good binding to SDL, called PyGame, which will allow you to create 2d games. There are even openGL bindings to allow you to create 3d games.

    However, for a good explanation of each programming language, I suggest you look at the wikipedia pages for PHP, Perl, and Python.


    Regards,

    cs_student

  • #9
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by netroact View Post
    That's interesting. Wonder why that never caught on like the web interface. I guess probably because PHP was introduced as the perfect marriage to MySql?
    Probably because a lot of the people that build CLI scripts have always used Perl or Python and have a lot of code they have written to draw off of for new programs. Plus the runtimes for both languages are commonly pre-installed in most Linux distros.

    Though it does make me curious to try and play around with making a PHP CLI script to see how well it works.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •