To clarify passing values to a subroutine
The arguments for a subroutine are treated as a list assignment to the @_ list. This script demonstrates a few key concepts:
my @entry = ('ListItem1', 'ListItem2');
$ScalarContext = &get_throughput($Var1, $Var2, @entry, $Var3, \@entry)
+;
@ListContext = &get_throughput($Var1, $Var2, @entry, $Var3, \@entry);
sub get_throughput {
my $GetsVar1 = shift @_; #@_ is a list of your arguments
my $Scalar = shift; # gets $Var2, @_ is the default for s
+hift
my ($List1, $List2) = @_; #@_ your list was added to @_ as indi
+vidual elements
my (undef, undef, $Var3) = @_; #undef discards return values
my $ListRef = $_[4]; #a reference to your list
#see docs for more info on refs
return wantarray ? @list : $Scalar;
}
Ardemus
"This, right now, is our lives."
|