poo( [ 1 .. 4 ], [ "goo", "doo", "moo" ], [ 6 .. 9 ] );
sub poo {
my ( $first, $second, $third ) = @_;
my @array = @{$second};
my $second = shift(@array);
my $length = length($second);
print( "@array", " $second", " $length\n" );
@array = @{$first};
my $first = shift(@array);
my $length1 = length($first);
print( "@array", " $first", " $length1\n" );
@array = @{$third};
my $third = shift(@array);
my $length2 = length($third);
print( "@array", " $third", " $length2\n" );
my $result = $length + $length1 + $length2;
print("$result\n");
}
####
"my" variable $second masks earlier declaration in same scope at test.pl line 9.
"my" variable $first masks earlier declaration in same scope at test.pl line 13.
"my" variable $third masks earlier declaration in same scope at test.pl line 17.
test.pl syntax OK
####
sub poo {
my ( $first, $second, $third ) = @_;
my @array = @{$second};
$second = shift(@array);
my $length = length($second);
print( "@array", " $second", " $length\n" );
@array = @{$first};
$first = shift(@array);
my $length1 = length($first);
print( "@array", " $first", " $length1\n" );
@array = @{$third};
$third = shift(@array);
my $length2 = length($third);
print( "@array", " $third", " $length2\n" );
my $result = $length + $length1 + $length2;
print("$result\n");
}
####
sub poo {
my ( $first, $second, $third ) = @_;
my $total_length = 0;
foreach my $array_ref (@_[1,0,2]) {
print join(' ', @$array_ref[1..$#$array_ref,0]),
' ', length($array_ref->[0]), "\n";
$total_length += length($array_ref->[0]);
}
print "$total_length\n";
}
####
sub poo {
my $total_length = 0;
foreach (@_[1,0,2]) {
print join(' ', @$_[1..$#$_,0]), ' ', length($_->[0]), "\n";
$total_length += length($_->[0]);
}
print "$total_length\n";
}
####
sub poo {
my $total_length = 0;
foreach my $array_ref (@_[1,0,2]) {
my ($first, @rest) = @$array_ref;
my $length = length($first);
print "@rest $first $length\n";
$total_length += $length;
}
print "$total_length\n";
}
####
sub poo {
my $total_length = 0;
foreach my $array_ref (@_) {
my ($first, @rest) = @$array_ref;
my $length = length($first);
print "@rest $first $length\n";
$total_length += $length;
}
print "$total_length\n";
}