Hello and welcome to the Webmasters Forums!. This is the best place to get webmasters resources for free. Get $2 for free today, read more - Make your payment today. Download premium and professional templates for free. Get free web hosting without ads, read more. You can get lot more by simply join with this forum. To gain full access to the forums you must sign up for a free account.


Post Reply  Post Thread 

Notes for Perl coders

Post Bank
Posting Manager
******

Posts: 995
Group: Forum Team
Joined: Sep 2006
Status: Online
Make money from now. You can make money just for posting on this forum. Every discussions on this community gives you more money. $2 minimum payout. So get your payment today, SignIn with this forum.

Signin to Remove this Post

bomber
Junior Member
*


Posts: 34
Group: Registered
Joined: Sep 2006
Status: Offline
Reputation: 0
Points: 250 (Donate)
Post: #1

Cool Notes for Perl coders


Skip this bit if you don't know Perl.

The major changes that most Perl coders find (in my experience at least) when using PHP are:

*

In PHP there is only one kind of array, and it's the hash (or named array), and you should treat every array like it's a hash (i.e., in a loop over an array, step through each key rather than going through the numbers on a list)
*

In PHP, variables, lists, and hashes are ALL signified by a $ at the front of the name. In Perl, depending on the context, either $, @, or % is required.
*

Filehandles are replaced by file pointers, and the file pointers are stored in a variable. This is different from Perl because in Perl, filehandles have their own namespace. So where in Perl one would do

open(MYFILE, ">newfile.txt") or die("Couldn't open file to write");

in PHP, this is

if (! $myfile = fopen("newfile.txt", "w")) die("Couldn't open file to write");

*

There is no regular expression operator in PHP - regular expression matching, substitution, etc. are all standard functions. This tidies up the syntax no end, in the author's opinion. However, on most PHP builds, PCRE is built in which supplies Perl-compatible regular expression functions for some seriously funky wizardry if you're that perverted a programmer that you feel you need to make your code illegible ;-)
*

In Perl, the default return value of a function (if one is not specifically given) is the result of the last statement in the function. In PHP, there is no default return value; this isn't in the PHP manual, however, so it may change in future. In all cases, it's wise to use a return value in a function.
*

Only one item can be returned from a function, though that one item can be a list. This is discussed later on.

18-09-2006 11:19 PM
Find all posts by this user Quote this message in a reply
Post Reply  Post Thread 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Cool How does it compare PHP to ASP? Perl? bomber 11 1,630 22-07-2007 03:17 PM
Last Post: maddog39

View a Printable Version
Send this Thread to a Friend
Subscribe to this Thread | Add Thread to Favorites
Rate This Thread:

Forum Jump:

Sign In to Remove Ads

Download 1000's of web templates. Unlimited access!
World's Best Web Hosting
Website of the Month

Create-a-Page for Free
SOTM June 2008


Accepting Submissions
for July 2008
Resources

Recommended Sites:



Visit our Sponsors!

Current time: 30-08-2008, 07:49 AM


Copyright © 2002-2008 MyBB Group
Powered By MyBB