Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: difficulty in understanding use of @_ and shift in a subroutine

by johngg (Canon)
on Oct 27, 2014 at 10:24 UTC ( [id://1105115]=note: print w/replies, xml ) Need Help??


in reply to difficulty in understanding use of @_ and shift in a subroutine

Note that while shift operates on @_ by default in a subroutine, in the main body of a script it operates on @ARGV, i.e. arguments supplied on the command line. This one-liner illustrates that.

$ perl -E 'say $x while $x = shift' aaa bbb ccc aaa bbb ccc $

I hope this is of interest.

Cheers,

JohnGG

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-04-25 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found