Front page | perl.perl5.porters |
Postings from January 2011
Given/when strangeness
Thread Next
From:
Alberto Simões
Date:
January 28, 2011 10:25
Subject:
Given/when strangeness
Message ID:
4D430A01.6080201@alfarrabio.di.uminho.pt
Consider
> #!/usr/bin/perl
> use 5.012;
>
> my $foo = { foo => 1 };
>
> given($foo) {
> when (/oo/) { say "OK" }
> default { say "NOK" }
> }
>
> say "OK" if $foo ~~ /oo/;
> say "OK" if /oo/ ~~ $foo;
I get
NOK
OK
OK
but I was expecting the first given/when clause to match.
Is this a bug or I missed some piece of documentation?
Thank you
ambs
--
Alberto Simões
Thread Next
-
Given/when strangeness
by Alberto Simões