Can someone tell me if this can be done and how as I have almost got it right, erm no I have not...
ozo gave me this one liner that works a treat
$r1t = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r1t] || $r1t;
for my $i (1 .. 4){
$r.$i.t = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r.$i.t] || $r.$i.t;
}
it does not return the same values as writing it long hand like this, any ideas if the code can be looped.
$r1t = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r1t] || $r1t;
$r2 = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r2t|| $r2;
$r3 = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r3 || $r3;
$r4 = (undef, $onename, $twoname, $threename, $fourname, $fivename)[$r4] || $r4t
Start Free Trial