@ver = $session->cmd("sh conf");
The variable here is ver
, which has the configuration file, that is, it has more than one line. So how to take an output of each line of the ver
variable without putting it in a loop?
@ver = $session->cmd("sh conf");
The variable here is ver
, which has the configuration file, that is, it has more than one line. So how to take an output of each line of the ver
variable without putting it in a loop?
Your @var
variable is an array - each element will contain one line.
You cannot get all lines without (implicitly or explicitly) looping over the entire array.
You can have perl do all the work for you though - for example, using join
, grep
or map
, depending what you want.
Examples:
#print all lines to a webpage
print join('<br />',@ver);
#print all lines with the word 'error' in it
print grep(/error/,@ver);