in reply to Idiom for setting variables to empty string if capture is undefined?
an idiom for avoiding this annoyance without turning the warnings off?
If you know the warnings are a possibility for particular statements, why not disable the warnings for those particular statements?:
my ($a, $b, $c, $d) = 'abcd' =~ /(w)(x)(y)(z)/; { no warnings 'uninitialized'; print "$a $b $c $d"; }
Or:
printf "%s %s %s %s\n", $a//'', $b//'', $c//'', $d//'';
Or, ensure they get some value:
my ($a, $b, $c, $d) = ( 'abcd' =~ /(w)(x)(y)(z)/, '','','','' );
|
|---|