Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: @_ the default variable?

by arturo (Vicar)
on Sep 14, 2001 at 22:26 UTC ( [id://112484]=note: print w/replies, xml ) Need Help??


in reply to @_ the default variable?

Outside of a *subroutine*, the default variable for list operations is @ARGV. Inside a subroutine, it's @_. Since none of your code occurs inside a subroutine, it's all attempting to operate on @ARGV.

Note, though, that while @_ is a respectable global, the @_ your subroutine sees is local to the subroutine. So unless you *explicitly* pass arguments to the subroutine, what you set @_ outside the subroutine won't make any valuables (update or, indeed, *values* =) available to the subroutine. i.e. :

sub jah { while (my $d = shift) { print "$d\n"; } } @_ = qw(foo bar bat); jah(); # produces no output jah(qw(foo bar bat)); # produces output

HTH

perl -e 'print "How sweet does a rose smell? "; chomp ($n = <STDIN>); +$rose = "smells sweet to degree $n"; *other_name = *rose; print "$oth +er_name\n"'

Replies are listed 'Best First'.
Re: Re: @_ the default variable?
by dga (Hermit) on Sep 14, 2001 at 23:12 UTC

    but &jah; would produce output.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-18 23:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found