> Robert Thompson wrote: > #!/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.
Here's one solution, though I am sure there will be better solutions offered. #!/usr/bin/perl @one = qw(1 2 3 4); @two = qw(5 6 7 8); @three = qw(9 10 11 12); @four = qw(13 14 15 16); @names = ( *one, *two, *three, *four ); foreach my $num(@names){ foreach(@$num){ $ref =~ s/(^\*[a-z]+\:+)//g; print "$num" . "_" . $_ . "\n"; } } If you wish to keep the original array names one_list etc., then: #!/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); @names = ( *one_list, *two_list, *three_list, *four_list ); foreach my $num(@names){ foreach(@$num){ $num =~ s/(^\*[a-z]+\:+)//g; $num =~ s/\_list//g; print "$num" . "_" . $_ . "\n"; } } Shaun --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.313 / Virus Database: 174 - Release Date: 02/01/2002 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]