Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Test if multiple variables are defined

by Eily (Chaplain)
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 browsing the Monastery: (11)
As of 2014-10-21 10:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls