I guess being a perl hack myself I'm not a huge fan of PHP. PHP doesn't come close to perl's regex powers and it's text processing speed. I guess you could also call me lazy in not wanting to declare all my variables just for a simple snippet.
The release of Perl 6 should, hopefully, convince people who have wondered off into PHP in search of a more web-friendly language to come back to the power of Perl.
Why did you move away from Perl into PHP yourself? Was it a commerical decision or were you more comftarble hacking PHP?
TMTOWTDI.
Wil
- wil
Mark Hensler posted this at 23:59 — 29th November 2001.
I never got very deep into PERL in the first place. I started teaching myself by hacking scripts. They were all flat file, and I never saw a PERL script that used a database. I caught a glimpse of some of the power PHP had with mySQL, and quickly re-wrote all my scripts into PHP & mySQL.
I've since learned that PERL has something or other (I forget the term), that allows it to interact with databases. DBI something or other. You can probably tell that I haven't done any research on this, but I do think about getting back into it now and then.
Mark Hensler
If there is no answer on Google, then there is no question.
nike_guy_man posted this at 02:07 — 30th November 2001.
I learned Perl first, and I had all my scripts written with PERL and flat file DBs
I'm trying to re-write everything in PHP using MySQL because PHP is HTML embedded, and I find it easier than using PERL.
I think PHP is more user friendly also, but thats just my opinion!
Yeah, perl has strong database support using the DBI module. If you run some benchmarks, using PHP is faster than Perl when working with databases and outputting via CGI to the web. However, it's all a different story when using mod_perl. That's when the power of Perl is unleashed and with persistent database connections (similar to PHP) you get faster benchmarks with Perl.
I agree that PHP is web-friendly in terms of people being able to code on top of their existing HTML effectively. But with the release of Perl 6 imminent, I think you'll find that Perl will change to adopt this trend. Although, using template parsers in perl it becomes stupidly simple to output HTML data along with your perl scribbles.
TMTOWTDI = There's more than one way to do it.
It's a Perl motto, because you can usually reach the same result through a hundred different methods. It has catched on, though, and it seems appropriate in this case. I personally find Perl better for myself because I like the powers of it's regex and text processing it brings. However others like PHP for the simplicity of coding (or any other reasons). No matter what your preference is; I'm sure we all reach the same place at the end.
Probably why PHP was also perceived as the database language is that when PHP became widespread on the Net, it used SQL databases as it's backend for scripts right from the start. Where perl originates as a *ix administrative language, a lot of information was stored and processed through flat files on local servers and that caught on when the language matured to the web.
Cheers
Wil
- wil
Mark Hensler posted this at 16:42 — 30th November 2001.
I prefer Perl for flat files and PHP for databases.
I used to use Perl to connect to a PostgreSQL database but then I realize that with PHP I can write scripts faster than Perl because PHP is embeded into the html file...
time is money sorry Perl
Mark, I don't know about mod_php. I've never tested anything with it. PHP keeps persistent connections with the web server anyway, so I don't quite understand why a mod would be needed for the server. Perl spawns child processes for each connection thus mod_perl is used to keep connections open.
Adolfo, well the easiest way (in any language) is to use HTML templates and keep your code well away. I have a farily decent HTML template parser written in Perl so I keep all my code in one script and then parse HTML documents as I wish. I then use markups like
<?php tag ?>
- similar to ASP style tags to - in my HTML and the template parses replaces them with variables defined in the local sub.
Works great for me, and I can pass on my HTML files to designers and they can work happyily away on then without screwing up any of my code. Makes my job much easier, and thus, as you requested, saves time.
A very simple HTML parser written in perl (very easily modified to PHP) could look something like:
<?php sub parse_template {
local(*FILE); # localise file handle local($file); # localise file path local($HTML); # localise HTML data
$file = $_[0];
open (FILE,\"<$file\") || die(\"Could not open $file <BR><BR> $!\");
while (<FILE>) { $HTML .= $_; }
close(FILE);
$HTML =~ s/<%(\w+) ?>
/${$1}/g;
print $HTML;
}
?>
By the way; why is the tag named PHP? Surely it should be named something like [code-syntax] or something? As it does the same job for a number of languages, not only PHP. Or are these boards PHP orientated?
Wil
- wil
Mark Hensler posted this at 01:59 — 2nd December 2001.
Yeah, I meant the [ PHP ] tag. Just wondering because it can be used for a number of similar languages like perl, python, javascript, C ... I just assumed that there's a PHP slant on these boards, maybe?
- wil
Mark Hensler posted this at 19:49 — 2nd December 2001.
Nope. It's a standard vBulletin tag that works on all boards I've tried it on.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.
Mark Hensler posted this at 17:06 — 29th November 2001.
He has: 4,048 posts
Joined: Aug 2000
What's wrong with PHP?
I can do some PERL. But it's been a while.
Wil posted this at 20:17 — 29th November 2001.
They have: 601 posts
Joined: Nov 2001
I guess being a perl hack myself I'm not a huge fan of PHP. PHP doesn't come close to perl's regex powers and it's text processing speed. I guess you could also call me lazy in not wanting to declare all my variables just for a simple snippet.
The release of Perl 6 should, hopefully, convince people who have wondered off into PHP in search of a more web-friendly language to come back to the power of Perl.
Why did you move away from Perl into PHP yourself? Was it a commerical decision or were you more comftarble hacking PHP?
TMTOWTDI.
Wil
- wil
Mark Hensler posted this at 23:59 — 29th November 2001.
He has: 4,048 posts
Joined: Aug 2000
TMTOWTDI? What is that?
I never got very deep into PERL in the first place. I started teaching myself by hacking scripts. They were all flat file, and I never saw a PERL script that used a database. I caught a glimpse of some of the power PHP had with mySQL, and quickly re-wrote all my scripts into PHP & mySQL.
I've since learned that PERL has something or other (I forget the term), that allows it to interact with databases. DBI something or other. You can probably tell that I haven't done any research on this, but I do think about getting back into it now and then.
Mark Hensler
If there is no answer on Google, then there is no question.
nike_guy_man posted this at 02:07 — 30th November 2001.
They have: 840 posts
Joined: Sep 2000
I learned Perl first, and I had all my scripts written with PERL and flat file DBs
I'm trying to re-write everything in PHP using MySQL because PHP is HTML embedded, and I find it easier than using PERL.
I think PHP is more user friendly also, but thats just my opinion!
Wil posted this at 10:24 — 30th November 2001.
They have: 601 posts
Joined: Nov 2001
Yeah, perl has strong database support using the DBI module. If you run some benchmarks, using PHP is faster than Perl when working with databases and outputting via CGI to the web. However, it's all a different story when using mod_perl. That's when the power of Perl is unleashed and with persistent database connections (similar to PHP) you get faster benchmarks with Perl.
I agree that PHP is web-friendly in terms of people being able to code on top of their existing HTML effectively. But with the release of Perl 6 imminent, I think you'll find that Perl will change to adopt this trend. Although, using template parsers in perl it becomes stupidly simple to output HTML data along with your perl scribbles.
TMTOWTDI = There's more than one way to do it.
It's a Perl motto, because you can usually reach the same result through a hundred different methods. It has catched on, though, and it seems appropriate in this case. I personally find Perl better for myself because I like the powers of it's regex and text processing it brings. However others like PHP for the simplicity of coding (or any other reasons). No matter what your preference is; I'm sure we all reach the same place at the end.
Probably why PHP was also perceived as the database language is that when PHP became widespread on the Net, it used SQL databases as it's backend for scripts right from the start. Where perl originates as a *ix administrative language, a lot of information was stored and processed through flat files on local servers and that caught on when the language matured to the web.
Cheers
Wil
- wil
Mark Hensler posted this at 16:42 — 30th November 2001.
He has: 4,048 posts
Joined: Aug 2000
So does mod_perl benchmark better than mod_php?
Adolfo posted this at 20:11 — 30th November 2001.
They have: 32 posts
Joined: Jan 2001
I prefer Perl for flat files and PHP for databases.
I used to use Perl to connect to a PostgreSQL database but then I realize that with PHP I can write scripts faster than Perl because PHP is embeded into the html file...
time is money sorry Perl
Adolfo
Wil posted this at 17:53 — 1st December 2001.
They have: 601 posts
Joined: Nov 2001
Mark, I don't know about mod_php. I've never tested anything with it. PHP keeps persistent connections with the web server anyway, so I don't quite understand why a mod would be needed for the server. Perl spawns child processes for each connection thus mod_perl is used to keep connections open.
Adolfo, well the easiest way (in any language) is to use HTML templates and keep your code well away. I have a farily decent HTML template parser written in Perl so I keep all my code in one script and then parse HTML documents as I wish. I then use markups like
<?php
tag
?>
Works great for me, and I can pass on my HTML files to designers and they can work happyily away on then without screwing up any of my code. Makes my job much easier, and thus, as you requested, saves time.
A very simple HTML parser written in perl (very easily modified to PHP) could look something like:
<?php
sub parse_template {
local(*FILE); # localise file handle
local($file); # localise file path
local($HTML); # localise HTML data
$file = $_[0];
open (FILE,\"<$file\") || die(\"Could not open $file <BR><BR> $!\");
while (<FILE>)
{
$HTML .= $_;
}
close(FILE);
$HTML =~ s/<%(\w+)
?>
print $HTML;
}
?>
By the way; why is the tag named PHP? Surely it should be named something like [code-syntax] or something? As it does the same job for a number of languages, not only PHP. Or are these boards PHP orientated?
Wil
- wil
Mark Hensler posted this at 01:59 — 2nd December 2001.
He has: 4,048 posts
Joined: Aug 2000
You mean the [ php ] tag?
It's named that because the color coding is specific to PHP. There is also a [ code ] tag that doesn't do any color coding.
I thought that the whole idea behing the apache mods is that the interpreter compiled into apache, and thus faster than keeping it external.
Mark Hensler
If there is no answer on Google, then there is no question.
Wil posted this at 16:50 — 2nd December 2001.
They have: 601 posts
Joined: Nov 2001
Yeah, I meant the [ PHP ] tag. Just wondering because it can be used for a number of similar languages like perl, python, javascript, C ... I just assumed that there's a PHP slant on these boards, maybe?
- wil
Mark Hensler posted this at 19:49 — 2nd December 2001.
He has: 4,048 posts
Joined: Aug 2000
Nope. It's a standard vBulletin tag that works on all boards I've tried it on.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.