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
chomp($output)or
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.
In Section
Seekers of Perl Wisdom