#!/usr/bin/perl
use strict;
use warnings;
use IO::Pipe;
my @systems = ('3par-S400','3par-E200');
my $system;
my $output;
my $command;
my %parvalues;
foreach $system (@systems) {
$output = run_command($system);
while (<$output>) {
next if (m/^$/);
last if (m/^Press.*/);
#print $_ . "\n";
$parvalues{$parelement} = ($_ .=~/(.*?)\t+/g) {
foreach my $parkeys (sort keys %parvalues){
print $parkeys, "\t", $parvalues{$parkeys}, "\n";
}
}
}
close($output);
}
sub run_command {
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 . $system . $space . $command;
my $cmd = new IO::Pipe;
$cmd->reader($do_command);
return $cmd;
}
======================
the above code results in the following error:
=======================
[bluethundr@cc126-200:~/perl] $:./3par-test2.pl
"my" variable $parkeys masks earlier declaration in same statement at ./3par-test2.pl line 25.
"my" variable %parvalues masks earlier declaration in same statement at ./3par-test2.pl line 25.
"my" variable $parkeys masks earlier declaration in same statement at ./3par-test2.pl line 25.
Global symbol "$parelement" requires explicit package name at ./3par-test2.pl line 23.
syntax error at ./3par-test2.pl line 23, near ") {"
syntax error at ./3par-test2.pl line 27, near "}"
Execution of ./3par-test2.pl aborted due to compilation errors.