use strict; use warnings; use Data::Dumper; my @array = (1,2,3,4); my @index = (1,3); &these(Index=>\@index); &those(Index=>\@index); sub these { my %args = @_; my @index = @{$args{Index}} || (); my $dump = Dumper($args{Index}); print "$dump"; $dump = Dumper(\@index); print "$dump"; } sub those { my %args = @_; my @index = @{$args{Index}} or (); my $dump = Dumper($args{Index}); print "$dump"; $dump = Dumper(\@index); print "$dump"; }
In reply to Setting defaults in subroutines by rbi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |