Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: help with perl understanding

by sundialsvc4 (Abbot)
on Jan 08, 2008 at 16:37 UTC ( #661123=note: print w/replies, xml ) Need Help??

in reply to help with perl understanding

(Whups... forgot to log-in.)

One thing that might really throw you for a loop is, when you define a sub, “where are the parameters?!” Perl has the very peculiar strategy of placing all of the arguments to a function into an array (strangely-named “@_”) which is available to the function, and you'll see people grabbing parameters off of it with things like shift (which pops the first element from an array).

However, I must say that I do admire a language that makes it a trivial task to reverse two variables that are out-of-order:   (This is a list assignment...)

($a, $b) = ($b, $a) if ($b > $a);
... and it is very nice to work in a system that has a very well-thought-out notion of “lists” and “hashes,” even though the language bumbles through some of these concepts with (in my opinion) rather sickening syntax. (Hold your nose when you get to “contexts.”)

And let's face it:   Messrs. Kernighan and Plauger put an assortment of “warts” into their language too, and by now we sort-of don't see them as warts anymore because we like what the language lets us do. The same's true of Perl. (It's a “teletype-era language” too, and sometimes it shows.) You'll scratch your head a lot, stick your tongue out at it a few times, roll your eyes and mutter under your breath, and in a matter of a few days or maybe a week or so, begin to get the groove of what all the fuss is about. Quite a few more “warts” here to be overlooked, but love is blind. ;-)

Replies are listed 'Best First'.
Re^2: help with perl understanding
by graq (Curate) on Jan 09, 2008 at 08:48 UTC
    ..... you'll see people grabbing parameters off of it with things like shift (which pops the first element from an array).

    Sorry to pedantic, what with you disliking so many Perl-isms, but pop pops, and shift shifts. ^_^

    Just hoping to clear up any future mishaps!

    -=( Graq )=-

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://661123]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2021-05-07 10:17 GMT
Find Nodes?
    Voting Booth?
    Perl 7 will be out ...

    Results (91 votes). Check out past polls.