http://qs321.pair.com?node_id=1067195


in reply to Variable assignment error checking

I think changing the sub to return $var in event of it being unable to complete its intended purpose would be the best option.

I don't like it but if changing the sub can't be done then this is the most consice method I could think of.

use strict; use warnings; my $var = 'foo'; my $tmp; $var = ( $tmp = return_false() ) ? $tmp : $var; print "$var\n"; $var = ( $tmp = return_true() ) ? $tmp : $var; print "$var\n"; sub return_true { return 'bar'; } sub return_false { return; }