sub some_sub{ my $item = shift; #assign the first element of @_ to $item my ($string); if ($item == 1){ #note == not = or = = $string = 'one'; } if ($item == 2){ $string = 'two'; } # and so on ... print "My number is $string." }
----
Coyote
In reply to Re: Using array elements as subroutine args
by Coyote
in thread Using array elements as subroutine args
by Tuna
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |