#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @poo = ( [1..4], ["goo", "doo", "moo"], [6..9] );
print Dumper (\@poo);
#here the Dumper module is used (it is VERY handy) to
#show the structure of @poo.
__END__
$VAR1 = [
[
1,
2,
3,
4
],
[
'goo',
'doo',
'moo'
],
[
6,
7,
8,
9
]
];
####
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @poo = ( [1..4], ["goo", "doo", "moo"], [6..9] );
#first we just have 3 things, just pass 'em! 3 things in the call!
poo (@poo);
sub poo
{
my ($lref1, $lref2, $lref3) = (my @lrefs) = @_;
#yes can do this, here we don't need individual ref's
#just shown to demo that you can do that...
foreach (@lrefs)
{
dump_lref ($_);
}
}
sub dump_lref
{
my $lref = shift; #same as $lref = @_; here
print "@$lref\n";
}
__END__
prints:
1 2 3 4
goo doo moo
6 7 8 9
####
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
my @poo = ( [1..4], ["goo", "doo", "moo"], [6..9] );
#now just pass a ref to the @poo list .....
poo (\@poo);
sub poo
{
my $ref_of_ref_to_list = shift;
foreach my $lref (@$ref_of_ref_to_list) #@does one level of de-ref
{
dump_lref($lref);
}
}
sub dump_lref ###WHOA same sub we used before!
{
my $lref = shift; #same as $lref = @_; here
print "@$lref\n";
}
__END__
prints:
1 2 3 4
goo doo moo
6 7 8 9