use strict;
use warnings;
use Data::Dumper;
my @list1 = qw(a b c);
my @list2 = qw(d e f);
changem([@list1], [@list2]);
print "\n=== After changem ===\n";
printf "%s\n", join q(, ), @list1;
printf "%s\n", join q(, ), @list2;
sub changem {
my $aref1 = shift or die "no list1";
my $aref2 = shift or die "no list2";
$aref1->[1] = 'Camel';
$aref2->[1] = 'LLama';
print "list1: " . Dumper($aref1);
print "list2: " . Dumper($aref2);
}
####
list1: $VAR1 = [
'a',
'Camel',
'c'
];
list2: $VAR1 = [
'd',
'LLama',
'f'
];
=== After changem ===
a, b, c
d, e, f
####
use strict;
use warnings;
my @a1 = qw(keats byron frost);
my @a2 = qw(marlowe shakespeare jonson);
handle_two( \@a1, \@a2 );
exit(0);
sub handle_two {
my ($aref1, $aref2) = @_;
for my $aref ($aref1, $aref2) {
do_something_with_one( $aref );
}
return;
}
sub do_something_with_one {
my ($aref) = @_;
printf "%s\n", join q(, ), @$aref;
return;
}
__END__
####
keats, byron, frost
marlowe, shakespeare, jonson
####
use strict;
use warnings;
use Data::Dumper;
my @list1 = qw(a b c);
my @list2 = qw(d e f);
changem(\@list1, \@list2);
print "\n=== After changem ===\n";
printf "%s\n", join q(, ), @list1;
printf "%s\n", join q(, ), @list2;
sub changem {
my $aref1 = shift or die "no list1";
my $aref2 = shift or die "no list2";
$aref1->[1] = 'Camel';
$aref2->[1] = 'LLama';
print "list1: " . Dumper($aref1);
print "list2: " . Dumper($aref2);
}
####
list1: $VAR1 = [
'a',
'Camel',
'c'
];
list2: $VAR1 = [
'd',
'LLama',
'f'
];
=== After changem ===
a, Camel, c
d, LLama, f