develooper Front page | perl.perl5.porters | Postings from January 2011

Given/when strangeness

Thread Next
From:
=?ISO-8859-1?Q?Alberto_Sim=F5es?=
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About