Hello list,
I am attempting to use some references for variable names in some loops, and
am having problems. Below is some test code for what I am attempting to accomplish.
#!/usr/bin/perl
@one_list = qw(1 2 3 4);
@two_list = qw(5 6 7 8);
@three_list = qw(9 10 11 12);
@four_list = qw(13 14 15 16);
foreach my $array (qw(one two three four)) {
foreach my $num ( @{$array}_list ) { <== Break here
print $array . "_" . $num . "\n";
}
}
The error I am getting is that the "_list" is not seen as part of the variable
name in the foreach loop.
Bareword found where operator expected at ./test.pl line 9, near "}_list"
(Missing operator before _list?)
syntax error at ./test.pl line 9, near "}_list"
I have tried all combinations of brackets and text I can think of, and putting
the extra text in the begining of the variable, with no success.
I need the output to be in the form "one_1", "one_2", "two_8", "three_11",
etc. I can just write a different foreach loop for each array, but that seems
redundant.
Thanks,
=-= Robert Thompson
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]