As Tanktalus said in Re: given-when construct unexpected bahavior wit arrays, this seems not natural.
Here, something doing what you want (I also change first grep with "eq"), but I feel bad with that trick :-)
.#!/usr/bin/env perl use v5.14; my @array = (0, 1000..10_000, 'abcd'); for my $element (qw/a ab abc 100 1000 10000 abcd/) { say "With grep:"; if (grep {$element eq $_} @array) { say "Element $element is there"; } else { say "Element $element is not there"; } say "With given-when:"; given ("_$element") { when ([map {"_$_"} @array]) { say "Element $element is there"; } default { say "Element $element is not there"; } } say ""; }
In reply to Re: given-when construct unexpected bahavior wit arrays
by brx
in thread given-when construct unexpected behavior with arrays
by mantager
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |