in reply to Re^5: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
in thread Understanding the benefit of Given/When ...
But when EXPR is one of the below exceptional cases, it is used directly as a boolean:
- [...]
- a regular expression match, i.e. /REGEX/ or $foo =~ /REGEX/, or a negated regular expression match (!/REGEX/ or $foo !~ /REGEX/).
- [...]
It makes sense. It allows
given ($x) { when (/abc/) { ... } when (/def/) { ... } when (/ghi/) { ... } }
to mean
if ($x =~ /abc/) { ... } elsif ($x =~ /def/) { ... } elsif ($x =~ /ghi/) { ... }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^7: Smart enough for Smart Match??? (was "Understanding ...Given/When" )
by LanX (Saint) on Mar 04, 2010 at 23:05 UTC | |
by ikegami (Patriarch) on Mar 04, 2010 at 23:46 UTC |