"be consistent" | |
PerlMonks |
given-when construct unexpected behavior with arraysby mantager (Sexton) |
on Jun 07, 2012 at 13:06 UTC ( [id://974933]=perlquestion: print w/replies, xml ) | Need Help?? |
mantager has asked for the wisdom of the Perl Monks concerning the following question:
Hi monks, I'm trying to understand the behavior of the given-when construct when I use an array reference in the "when" clause. I saw a similar example in "Programming Perl - 4th ed." but it's not doing what I expected. I have this test case:
It yields this result:
The 'grep' gets it right every time. The given-when construct finds elements 'a', 'ab' and 'abc' even if the're not in @array. The funny thing is: if I remove the 0 from @array, elements 'a', 'ab' and 'abc' are reported as "not there", so the matching element seems to be the 0. I'm rather puzzled. Can someone explain this? Thanks, bye.
Back to
Seekers of Perl Wisdom
|
|