Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Re: Defining Subroutines

by rir (Vicar)
on Oct 24, 2002 at 04:11 UTC ( [id://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?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-07-15 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.