Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Idiom for setting variables to empty string if capture is undefined?

by BrowserUk (Patriarch)
on Dec 06, 2015 at 07:43 UTC ( [id://1149494]=note: print w/replies, xml ) Need Help??


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)/, '','','','' );

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1149494]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-04-18 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found