Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Test if multiple variables are defined

by Eily (Curate)
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 drinking their drinks and smoking their pipes about the Monastery: (13)
As of 2015-07-31 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (276 votes), past polls