Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Re: Defining Subroutines

by rir (Vicar)
on Oct 24, 2002 at 04:11 UTC ( #207621=note: print w/replies, xml ) Need Help??


in reply to Re: Defining Subroutines
in thread Defining Subroutines

Not quite, using the ampersand causes the routine call to use the existing @_ as the default arguments. If you provide arguments they are used instead.
sub z { my $i =1; foreach (@_) { print "$i : $_\n"; $i++; } } sub x { &z; # 1 &z( "good", "bye"); &z; # same as one again &z(); # called with empty list } x( "say", "hello");

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (7)
As of 2022-12-07 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?