in reply to Re^6: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
in thread Understanding the benefit of Given/When ...
OMG it took me a while to understand it ... yes it makes sense:
use 5.010; use strict; use warnings; my @a=('abc'); given (@a) { print "$_\n"; when (/ARRAY/ ) { print "ARRAY\n" ;continue} # regex-match! when (/abc/ ) { print '/abc/'."\n" ;continue} # no match when (qr/abc/ ) { print 'qr/abc/'."\n" ;continue} # smart-match! }
OUTPUT:
ARRAY(0x8255a70) ARRAY qr/abc/
Sigh ... do you agree that the docs could be more explicit? :)
Cheers Rolf
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^8: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
by ikegami (Patriarch) on Mar 04, 2010 at 23:46 UTC |