tian
asked on
how to print out list of lists
.......
push(@$list{$_},$name);
......
how can I print out all elements of this list of lists? Thanks.
push(@$list{$_},$name);
......
how can I print out all elements of this list of lists? Thanks.
ASKER
Thanks Kai,
I still can not solve it seeing your comment.(maybe i am too stupid)
In fact What I am trying to do is:(you can see my last question:"implement it in elegant way"for reference)
....
foreach $f (@files){
$name=$f;
$open(FILE,$f) || die "cannot open";
while(<FILE>){
if(exists $pattern{$_}){
push @{$list{$_}},$name; # push(@$list{$_},$name); doesnot work
}
}
}
....
#then how to print content of the @list{pattern1} @list{pattern2}.......
I still can not solve it seeing your comment.(maybe i am too stupid)
In fact What I am trying to do is:(you can see my last question:"implement it in elegant way"for reference)
....
foreach $f (@files){
$name=$f;
$open(FILE,$f) || die "cannot open";
while(<FILE>){
if(exists $pattern{$_}){
push @{$list{$_}},$name; # push(@$list{$_},$name); doesnot work
}
}
}
....
#then how to print content of the @list{pattern1} @list{pattern2}.......
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Am I right?
In general printing LoLs works like:
@strArray = ("a;b;c;d", "e;f;g;h", "i;j;k" );
for $i ( 0 .. 2 )
{
push @LoL, [ split /;/, $strArray[$i] ];
}
for ( @LoL )
{
for ( @$_ )
{
print "$_\n";
}
}
Best regards,
Kai.