[Israel.pm] given/when bug

Shimon Cohen shimoco at gmail.com
Sun Mar 25 17:07:56 PDT 2012


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 <ynonperek at gmail.com> 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
> Perl at perl.org.il
> http://mail.perl.org.il/mailman/listinfo/perl
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.perl.org.il/pipermail/perl/attachments/20120326/c05469c5/attachment.htm 


More information about the Perl mailing list