More careful look at the warnings gives a clue: The range operators evaluated in scalar context, and the when-s EXPRs are not trying to smart match against $foo at all.
Let the script run on multi lines input, and it will do other than default. On Mon, Mar 26, 2012 at 2:07 AM, Shimon Cohen <[email protected]> wrote: > Hi > > Im not sure its "normal arrays" in your when-s. > its seems the parenthesis are part of when syntax, > and the given statement is equivalent to: > > given ($foo) { > say 'small' when 1..10; > say 'medium' when 11..20; > say 'large' when 21..30; > default { say 'unknown' } > } > > However, perl -w warn the same for both versions. > > Shimon. > > On Mon, Mar 26, 2012 at 12:28 AM, ynon perek <[email protected]> wrote: > >> Hi All, >> >> Started using given/when and accidentally coded this bug: >> https://gist.github.com/2200399 >> >> I now know that I need to use an arrayref inside then when-s, but my >> question - what did perl think I meant with normal arrays ? will the code >> ever do anything other than default ? how ? >> >> Thanks, >> Ynon >> >> >> _______________________________________________ >> Perl mailing list >> [email protected] >> http://mail.perl.org.il/mailman/listinfo/perl >> > >
_______________________________________________ Perl mailing list [email protected] http://mail.perl.org.il/mailman/listinfo/perl
