views:

42

answers:

2
@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?

+6  A: 

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);
Konerak
+1  A: 

How about :

print join("\n", @ver);
Peter Tillemans