oakb has asked for the wisdom of the Perl Monks concerning the following question:
...but it is terribly inelegant. I would like to replace it with a simple grep:my $usefulans; foreach ( @$qablock ) { if ( $$_[ 0 ] eq $answer ) { $usefulans = [ @$_ ]; } } print "\t\t----> @$usefulans\n";
...but nothing (and I mean NOTHING...I've tried every permutation I could imagine, even throwing a map in for good measure) I do makes it work. No matter how I try to dereference the array of arrays, I end up with the reference address (e.g. "ARRAY(0x7fed6283b5d0)") instead of the legitimate list of data that I get from the foreach above. Am I stuck with the foreach, because this is something that grep just can't handle? Or is there something I'm doing wrong, which, done correctly, would make the grep work?my $usefulans = grep { $$_[ 0 ] eq $answer } @$qablock; print "\t\t----> @$usefulans\n";
|
|---|