Lightning wrote:
I mean I love php, i just do and i just dont like Perl
cause i never
did understand it to well..
Interestingly enough, I can't really say I don't like PHP. I just sort
of feel that Perl already does the job, so can I can't get myself to
learn PHP. :)
But as I said, I have a hard time reading perl..
Please trust me -- I know *exactly* how you feel! I was in the same
position not too long ago. Heh, I even remember seeing this statement:
$a =~ s/$/\/\//;
For obvious reasons, this is discouraged even among Perl programmers.
It's called the 'leaning toothpick syndrome'. An equivalent statement
would be:
$a =~ s!$!//!;
but it's actually the same as
$a .= "//";
or
$a = "$a//";
or
$a = $a . "//";
which is of course more readable by orders of magnitude.
oh and i wont even look at regexps..
It is often possible to write Perl code which includes a regexp in such
a way that the reader of the code doesn't have to read the regexp or
understand how the regexp really works, but can nevertheless see what it
does or what it's for:
if ($url !~ m!^(\w+)://((?:\w+\.)*\w+)(?::(\d+))(/.*)$!) {
return "Invalid URL format.";
} else {
my ($protocol, $host, $port, $path) = ($1, $2, $3, $4);
# ...
# ... continue processing ...
# ...
}
It should be pretty obvious without looking at the regexp that its
purpose is to check URL syntax and to extract the protocol, hostname,
port number and path from it.
(I've only just grabbed this regexp out of the air, so please don't hit
me if it's completely wrong ...)
Timwi