#!/usr/bin/perl use strict; use warnings; use IO::Pipe; use IO::Handle; my @systems = ('3par-S400','3par-E200'); my $system; my $output; my $command; STDOUT->autoflush(1); print "this is test statement one!\n"; foreach $system (@systems) { $output = run_command($system); STDOUT->autoflush(1); print "this test is just before the while loop!\n"; while (<$output>) { next if (m/^$/); last if (m/^Press.*/); my (@headers) = /\d\d:\d\d:\d\d/; STDOUT->autoflush(1); print "This is a test before the loop from insde while!\n"; foreach my $header(@headers) { STDOUT->autoflush(1); print "this is a test\n"; STDOUT->autoflush(1); print "$header \n"; } } close($output); } sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $command = "statvv -ni"; my $space = " "; #The following is bad but it works for now.. my $do_command = $protocol . $space . "-l $user" . $space . $system . $space . $command; my $cmd = new IO::Pipe; $cmd->reader($do_command); return $cmd; }