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; }
In reply to Re: Variable assignment error checking
by rnewsham
in thread Variable assignment error checking
by nathaniels
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |