my $memType = [];
my $portOp = [];
my $fo = "aster.out.DRAMA.READ.gz";
if($fo =~/aster.out\.(.*)\.(.*)\.gz/){
push (@{$memType},$1);
push (@{$portOp},$2);
}
print Dumper @{$memType};
foreach my $mem (keys %{$portCapability->{@{$memType}}}){
//How to use the array ref memType inside a hash//
print "entered here\n";
//cannot post the rest of the code for obvious reasons//
}
I am not able to enter the foreach loop . Can anyone help me fix it? Sorry this is not the complete code . Please help me.
This doesn't do what you may think it means.
$portCapability->{@{$memType}}
as a hash reference.@{$memType}
is evaluated in scalar context, thus giving the size of the array.I aren't quite sure what you want, but would
work?
If, however, you want to slice the elements in
$portCapability
, you would need somethink likeThis evaluates to a list of hashrefs. You can then loop over the hashrefs, and loop over the keys in an inner loop:
If you want a flat list of all keys of the inner hashes, but don't need the hashes themselves, you could shorten above code to