My personal opinion is that it depends on what you will use it for and how much programming you've done in the past.
PHP is an excellent language for embedding code into HTML, and has built-in support for mySQL. However, I wouldn't really advise using it for big programs because the embedded nature makes it hard to maintain control flow etc.
On the other hand, Perl is also excellent, but you have to generate the whole page, not just parts of it (as you do with PHP). It can also be used for other purposes (e.g., server admin, file processing, etc.)
I have a smiliar situation with you and finally I decided to learn Perl. I made this decision because I found that Perl is more versatile, flexible and powerful. As a matter of fact, after learned Perl for a while, I found myself automatically familiar with PHP. Anyway, this is my personal experience.
Thank you all.
I agree to with simon. But you will find more (simply & small) code samples for PHP. IMHO Perl is not so easy to set up on a server.
Here are some stats about posts on webmasterworld.com:
Perl Server Side CGI Scripting: Post 23,637
PHP Server Side Scripting: Post62,026
IMHO PHP is easier to learn and apply to websites than Perl. However, once you get past the learning curve the it could be that Perl is a bit more versitile.
For myself, I chose PHP 7-years ago because of its ease of use and because I pretty much only do coding for websites.
alexn makes a generally accepted statement about PHP in that it is ok for small projects.
But perl starts to show its versatility when dealing with large systems that span across several, perhaps hundreds of servers.
As a programmer of both, I have to say that perl is the way to go. It does have a higher learning curve than PHP but once you understand the language you can get MUCH more done in less time than the same amount of aptitude in PHP can accomplish.
The amount of posts in the PHP forum doesn't really indicate anything about PHP being better. To me it seems to show that there are more PHP noobs and there are better places to get help with perl *cough*perlmonks*cough (Sorry Brett).
My Two Cents...
I have been codeing in Perl for over 10 years and I have NEVER found anything I can not do on the server with Perl. The learning curve, don't let that scare anybody, it is about the same as any other language. Once you know how to program, learning a language is the easy part.
Programing in general is just logic. If you know how to play chess, you can learn to program with ease.
The way I learned perl was to download other peoples scripts and study them, modify them and build something from them. I did not buy a Perl book for 2-3 years, and only then to reference, have never actually read one.
If your sole objective is web application, go Php. Otherwise go Perl.
I dislike PHP in many ways but I use it because:
1) I use a CMS written in PHP and I need to modify/extend it. There are a LOT of PHP CMSes around.
2) It has a huge range of functions and almost anything you can wish for is available.
3) It mixes very nicely with HTML
4) On-line documentation is superb
I dislike it because it is ugly. Function names are inconsistent. It is not really dynamic - for example you can not re-define a function (once a function is defined, you can not change it).
I would never use PHP for anything other than web pages.
Incidentally it is not true that you must create entire web pages in Perl - there is an Apache module that allows you to place fragments of Perl within an HTML page - just like PHP.
I have to say I am not that enamoured either language in-itself, but their popularity gives them an edge (e.g. cheap hosting, lots of libraries available, lots of documentation) over what I would consider better languages in themselves (TCL, Ruby).
Can I just say: benchmark, error handling. :)
both are good if your going to do a lot of sys admin stuff then perl, especially if its cross platform, is a good choice since there are a lot of prewritten things out there for that.
If you just need a general purpose scripting language that is qucik to learn and don't need prewritten sys admin tools go with php.
When it comes down to it though I can use both equally and prefer php if there isn't something written to do the job already.
PHP is faster when you're dealing with basic websites with a database backend. In websites, I use Perl for the heavy lifting like complex SOAP or XML parsing, then feed the results back to PHP for display.
I'm a devotee to PHP for websites but I wouldn't think of using it for difficult server work.
I'd say start with PHP, then as your skill and needs grow, start looking at Perl. Learning PHP before you learn Perl will probably make you a better Perl programmer anyway :-)
Basic Perl CGI scripts are inferior to PHP.
I say: For a simple, unknown environment use PHP.
If you can use frame works like HTML::Mason (r0xx0rs ^^ )or HTML::Template use Perl.
When you use Perl you should be able to install any modul form CPAN.
You do not need "build in" support for xyz. You need the rights to install more modules.
Perl mixes nicely with HTML. (embeded)
Perl is fast.
Perl is easy.
Perl connects easily to almost any DB known to mankind.
You can do almost anything with Perl.
You need to tune the installation of your Server and Apache. Thanks to the cpan shell this is very easy. But you need the rights to do it. ;)
Or in other words:
If I had to deploy a web-application wich should run on every "out of the box" LAMP system via FTP upload I would use PHP.
THIS was the reason for the great success of PHP. But today root/dedicated servers are cheap.
[edited by: Xenon001 at 9:42 am (utc) on Jan. 11, 2006]
and welcome to WebmasterWorld Xenon001
I was in your position and I did not know which to start, but due to nature of my work, I finally decided to learn php, because it is easy to learn and there is dozens of easy to flow tutorials in online.