in reply to Re: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
in thread Understanding the benefit of Given/When ...
Have a look at the last code in the OP (I updated it 10 minutes after posting)
given(@array) and given(\@array) both produce the same ref in $_, but the smartmatch doesn't work as documented.
While I can understand why to limit given to simple scalars I think the docs should either be updated to reflect this behaviour or it's a bug.
UPDATE: you should add continues to se which clauses are true
my @a=('abc',1); given (@a) { when (/abc/ ) { print "abc\n" ;continue} when (1 ) { print "#\n" ;continue} when (['abc',1]) { print "copy\n" ;continue} when (\@a ) { print "self\n" } }
OUTPUT
Argument "abc" isn't numeric in smart match at /home/lanx/tmp/ike_give +n.pl line 9. # copy self
Cheers Rolf
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
by ikegami (Patriarch) on Mar 04, 2010 at 18:04 UTC | |
by LanX (Saint) on Mar 04, 2010 at 18:10 UTC | |
by ikegami (Patriarch) on Mar 04, 2010 at 19:08 UTC | |
by ikegami (Patriarch) on Mar 04, 2010 at 19:17 UTC | |
by LanX (Saint) on Mar 04, 2010 at 23:05 UTC | |
|
In Section
Seekers of Perl Wisdom