in reply to Idiom for setting variables to empty string if capture is undefined?
There are several ways how to prevent the warnings. The most common one is to test whether there was a match:
if (my ($x, $y) = 'ab' =~ /(x)(y)/) { print "$x$y\n"; }
Another possibility it to use the convenient defined-or operator (Perl 5.10+ needed):
my ($x, $y) = 'ab' =~ /(x)(y)/; print $x // q(), $y // q(), "\n";
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Idiom for setting variables to empty string if capture is undefined?
by karlgoethebier (Abbot) on Dec 06, 2015 at 22:20 UTC |