Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Shift function and file opening

by bm (Hermit)
on Sep 04, 2003 at 12:08 UTC ( #288837=note: print w/ replies, xml ) Need Help??


in reply to Shift function and file opening

my $file = shift || 'foo.html';
is equivalent to:

my $arg = shift; my $file; if ($arg) { $file = $arg; } else { $file = 'foo.html'; }
As mentioned, what the shift is doing depends on the context of your snippet in your program. If it appears within a sub block, then it is removing the first element of the argument list. If it is in the main body of your script, then it is removing the first element of @ARGV (which contain the arguments passed to your script from the command line).
--
bm


Comment on Re: Shift function and file opening
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-28 03:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (178 votes), past polls