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

Re: Re: perlapp, die, and __DATA__

by integral (Hermit)
on Apr 25, 2003 at 06:44 UTC ( #253081=note: print w/ replies, xml ) Need Help??


in reply to Re: perlapp, die, and __DATA__
in thread perlapp, die, and __DATA__

Perl passes by alias, so using @_ instead of @ARGV will not prevent worries about modifying the global @ARGV. Options are to make a lexical copy (my @args = @ARGV) or to localise (local @ARGV = @ARGV).

use strict; use warnings; print "1: @ARGV\n"; foo(@ARGV); print "3: @ARGV\n"; sub foo { print "2a: @_\n"; $_[0] = "foobar"; print "2b: @_\n"; }

(Note however that the elements are aliased indivualluy into @_ not the whole array, so if @ARGV is empty there will be no modification as you are then adding a new element to @_ instead of modifying an element in @ARGV through @_.)

--
integral, resident of freenode's #perl


Comment on Re: Re: perlapp, die, and __DATA__
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (13)
As of 2015-07-07 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (90 votes), past polls