|Syntactic Confectionery Delight|
given-when construct unexpected behavior with arraysby mantager (Sexton)
|on Jun 07, 2012 at 13:06 UTC||Need Help??|
mantager has asked for the
wisdom of the Perl Monks concerning the following question:
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?