On Mon, Sep 29, 2003 at 11:04:46PM +0300, Ville Jungman wrote:
> This is real example from what i was doing yesterday:
> if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
> $subs->paivita($x);
> $udat{x}=$lisax;
> $udat{y}=$lisay;
> }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
> $udat{y}=$lisay;
> }
>
> If using return values, this could be wrote as:
> ($udat{x},$udat{y})=
> if($subs->anna_tilavuus($x+$lisax,$y+$lisay,$z) < 100){
> $subs->paivita($x);
> retlast($lisax,$lisay)
> }elsif($subs->anna_tilavuus($x,$y+$lisay,$z) < 100){
> retlast(undef,$lisay);
> }
> ;
You can do this already with "do" blocks.
my $condition = 1;
($x, $y) = do {
if ($condition) { 42, 43 }
else { 44, 45 }
};
print "$x : $y\n";
If it makes you happy, you can even add -->
sub retlast { @_ }
But the analogy with return/last is likely to confuse -- why can
you use retlast() in places where neither return() or last() make
any sense?
--
Steve
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]