Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Set condition only if array becomes empty

by virtualsue (Vicar)
on Sep 27, 2017 at 09:23 UTC ( #1200181=note: print w/replies, xml ) Need Help??

in reply to Set condition only if array becomes empty

You already have valuable hints in this thread. Make sure you strip or check for a newline at the end of the lines that your 'cmd'or 'get_response' returns, unless they already do that. It's easy to forget this (I often do). Either
if ($output eq "3000\n")
should work. If it doesn't, searching for newline removal here and on the web will come up with a lot of discussion about it. Some ways to check if an array is empty:
    if (! @array) {}
    if (scalar(@array) == 0) {}
In the code you showed us, you might just check if $output is "" or whatever happens when you run $rh->get_response on a command that didn't provide any output. I also would be curious as to where the "3000" came from as it sounds like a magic number, but for all I know that's guaranteed to be fine for the entire lifetime of your script.
  • Comment on Re: Set condition only if array becomes empty

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2021-04-23 08:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found