bluethundr has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use IO::Pipe; use IO::Handle; use IO::File; my $system; my @systems = ( '3par-S400', '3par-E200' ); open( MYFILE, '>>data.txt' ); foreach $system (@systems) { my $output = run_command($system); while (<$output>) { next if (m/^$/); last if (m/^Press.*/); print MYFILE $_ . "\n"; } } close(MYFILE); open( MYFILE, '<data.txt' ); while (<MYFILE>) { next if (m/^$/); last if (m/^Press.*/); my ( $line, %seqs, $sequence, $date, $orig, $desg, $body ); if ( $line =~ /(\d+\-\d+\-\d+\s\d+\d+\ d+\ +)/ ) { $date = $1; } else { $seqs{$sequence} = "$date;$orig;$desg;$body"; } } sub run_command { my $user = 'gmon'; my $system = shift; my $protocol = 'ssh'; my $ssh_flags = "-l $user"; my $command = "statvv -ni"; my $space = " "; my $do_command = $protocol . $space . $ssh_flags . $space . $system . $space . $c +ommand; my $cmd = IO::Pipe->new; $cmd->reader($do_command); return $cmd; } close(MYFILE);
[bluethundr@cc126-200:~/perl] $:./3par-test5.pl Use of uninitialized value in pattern match (m//) at ./3par-test5.pl l +ine 29, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 1. Use of uninitialized value in hash element at ./3par-test5.pl line 30, + <MYFILE> line 1. Use of uninitialized value in pattern match (m//) at ./3par-test5.pl l +ine 29, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in concatenation (.) or string at ./3par-te +st5.pl line 30, <MYFILE> line 2. Use of uninitialized value in hash element at ./3par-test5.pl line 30, + <MYFILE> line 2.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: trouble assigning values to hash
by ikegami (Patriarch) on Aug 26, 2010 at 23:07 UTC | |
|
Re: trouble assigning values to hash
by AnomalousMonk (Archbishop) on Aug 26, 2010 at 23:48 UTC | |
by ikegami (Patriarch) on Aug 27, 2010 at 00:46 UTC | |
by bluethundr (Pilgrim) on Aug 27, 2010 at 07:56 UTC | |
by AnomalousMonk (Archbishop) on Aug 27, 2010 at 14:43 UTC | |
by bluethundr (Pilgrim) on Aug 27, 2010 at 17:49 UTC | |
|