Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: trouble understanding code, and shift() w.o args

by GotToBTru (Curate)
on Aug 04, 2011 at 16:47 UTC ( #918588=note: print w/ replies, xml ) Need Help??


in reply to Re^2: trouble understanding code, and shift() w.o args
in thread trouble understanding code, and shift() w.o args

Yes, that's how you'd add a third argument. You would need to also add a third shift in the subroutine to use it.

Perl's handling of parameters to subroutines is strange; every other language I have used requires the parameters be listed in the subroutine definition. I have often seen

sub translate { my ($noun, $verb, $object) = @_; my $german = "$noun $object $verb"; return($german); }

in order to document what the subroutine expects: 1) three arguments, 2) in the order noun, verb, object. Also, that would be less confusing to a novice Perl programmer because it explicitly names @_, instead of assuming you know about it. Which, of course, now you do.


Comment on Re^3: trouble understanding code, and shift() w.o args
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (12)
As of 2014-12-22 21:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (130 votes), past polls