in reply to Given When Syntax
Normally I recommend replacing given/when with for/if-constructs.
But in this particular case I don't understand why you are not simply using an array or a hash, holding the number's names.
Cheers Rolf
( addicted to the Perl Programming Language)
Ehm... did you activate switch?
use feature "switch"; or use 5.010;
DB<103> @num=qw/Zero One Two Three Four/ => ("Zero", "One", "Two", "Three", "Four") DB<104> $var=2; print "$var is $num[$var]"; => 1 2 is Two
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Given When Syntax
by Deep_Plaid (Acolyte) on Mar 15, 2014 at 16:20 UTC | |
by LanX (Saint) on Mar 15, 2014 at 16:29 UTC |