C
craigandjeanne
Hi,
The following code, I thought, should have worked properly for looping
through an array passed as a reference to a function. But, instead I
end up with the error message: "Can't use string ("string") as an ARRAY
ref while "strict refs" in use at ./test.pl line 29, <FILE> line 2. The
following is a cut down version of the actual code.
my @list = ( 1, 2, 3 );
server_work(@list);
exit;
sub server_work {
my ($a_ref) = shift;
my $val;
foreach $val (@{$a_ref}) {
print STDOUT $val;
}
return(1);
}
What am I doing wrong?
The following code, I thought, should have worked properly for looping
through an array passed as a reference to a function. But, instead I
end up with the error message: "Can't use string ("string") as an ARRAY
ref while "strict refs" in use at ./test.pl line 29, <FILE> line 2. The
following is a cut down version of the actual code.
my @list = ( 1, 2, 3 );
server_work(@list);
exit;
sub server_work {
my ($a_ref) = shift;
my $val;
foreach $val (@{$a_ref}) {
print STDOUT $val;
}
return(1);
}
What am I doing wrong?