in reply to Would you use a switch instead?
There is the Switch module, but it's a source filter and considered evil. Perl 5.10 has the given/when statements, that are the equivalent of Switch.
If you're stuck on an earlier perl, you could also use something like:
for ($value) { /aaa/ && do { $foo = 'wanna'; last }; /bbb/ && do { $foo = 'be'; last }; /ccc/ && do { $foo = 'startin'; last }; $foo = 'somethin'; }
Tested with dodgy eyes only!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Would you use a switch instead?
by AnomalousMonk (Archbishop) on Jul 04, 2009 at 16:15 UTC | |
by GrandFather (Saint) on Jul 04, 2009 at 22:32 UTC | |
by ysth (Canon) on Jul 05, 2009 at 08:42 UTC |