Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Test if multiple variables are defined

by Eily (Deacon)
on Jun 26, 2013 at 22:06 UTC ( #1040856=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Test if multiple variables are defined
in thread Test if multiple variables are defined

use strict; use warnings; use Data::Dumper; my ( $ipaddress, $prefix, $interface, $device, $location) = ('no_ws', +' some_ws ', undef, ' lotsa ws ', undef); s/^\s+|\s+$//g for grep {defined $_} ( $ipaddress, $prefix, $interface +, $device, $location); print Dumper ( $ipaddress, $prefix, $interface, $device, $location);
(Thanks AnomalousMonk for the strings :D). So this yields:
$VAR1 = 'no_ws'; $VAR2 = 'some_ws'; $VAR3 = undef; $VAR4 = 'lotsa ws'; $VAR5 = undef;
It works fine.


Comment on Re^4: Test if multiple variables are defined
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (7)
As of 2014-12-26 11:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (171 votes), past polls