Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: passing an array and some scalars to a subroutne

by olus (Curate)
on Mar 06, 2009 at 14:22 UTC ( #748866=note: print w/ replies, xml ) Need Help??


in reply to passing an array and some scalars to a subroutne

You can also shift the args.

Also, since the arguments are passed as a list, you could start considering passing references to the arrays and deref them in the sub. That way you can pass other args after the first array, or multiple arrays (that would otherwise be considered a single one).

use strict; use warnings; my $arg1 = "abc"; my @arg2 = (1, 2, 3, 4); show_args($arg1, \@arg2); sub show_args { my $arg1 = shift; my $arg2 = shift; my @lines = @{$arg2}; print @lines; }


Comment on Re: passing an array and some scalars to a subroutne
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2015-07-05 23:38 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 (68 votes), past polls