nysus has asked for the wisdom of the Perl Monks concerning the following question:
I've come across a minor annoyance demonstrated by this code snippet:
my ($a, $b, $c, $d) = 'abcd' =~ /(w)(x)(y)(z)/; print "$a $b $c $d";
Running this results in a bunch of "Use of uninitialized value" errors. To appease Perl, I am forced to test each variable to see if it's undefined and set each variable to an empty string if it is.
Are there any suggestions out there for an idiom for avoiding this annoyance without turning the warnings off?
$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon";
$nysus = $PM . $MCF;
Click here if you love Perl Monks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Idiom for setting variables to empty string if capture is undefined?
by BrowserUk (Patriarch) on Dec 06, 2015 at 07:43 UTC | |
|
Re: Idiom for setting variables to empty string if capture is undefined?
by choroba (Cardinal) on Dec 06, 2015 at 07:47 UTC | |
by karlgoethebier (Abbot) on Dec 06, 2015 at 22:20 UTC | |
|
Re: Idiom for setting variables to empty string if capture is undefined?
by Corion (Patriarch) on Dec 06, 2015 at 08:32 UTC | |
|
Re: Idiom for setting variables to empty string if capture is undefined? (map defined $_ ? $_ : '' , m//
by Anonymous Monk on Dec 06, 2015 at 09:06 UTC | |
|
Re: Idiom for setting variables to empty string if capture is undefined?
by soonix (Chancellor) on Dec 06, 2015 at 17:06 UTC | |
|
Re: Idiom for setting variables to empty string if capture is undefined?
by Anonymous Monk on Dec 06, 2015 at 18:44 UTC |