J
jesse
I have a perl script that parses a file of backup failures. I have it
print what failed and how many times it's failed. The log file lines
look like this:
c3devweb3 C:\\
c3devweb3 D:\\
This is the name of the server and what failed. The scripts seems to
be working okay but there are some problems in the output. Here is
the script.
#!/usr/bin/perl
#
use:strict;
use warnings;
my $file = "/export/home/jhardy/failed";
my %failures;
open(FAILED, "<", $file) or die "$!\n";
while (<FAILED>) {
s/#.*//;
next if /^(\s)*$/;
my $failure = ( split,(/ /, $_) );
$failures{$failure}++;
}
close(FAILED);
foreach $failure ( keys %failures) {
print "The backup of $failure has failed $failures{$failure}
times this month\n";
}
The output I get is this:
The backup of c3duoraint1-bkup /
has failed 2 times this month
The backup of c3duoraint1-bkup /export/home
has failed 2 times this month
The output needs to be on one line ie;
The backup of c3duoraint1-bkup / has failed 2 times this month.
Can someone tell me what I'm doing wrong. I am also getting an error
on the split it says the way I'm using it is deprecated and I'm not
sure what I'm doing wrong there either.
Thanks,
Jesse
print what failed and how many times it's failed. The log file lines
look like this:
c3devweb3 C:\\
c3devweb3 D:\\
This is the name of the server and what failed. The scripts seems to
be working okay but there are some problems in the output. Here is
the script.
#!/usr/bin/perl
#
use:strict;
use warnings;
my $file = "/export/home/jhardy/failed";
my %failures;
open(FAILED, "<", $file) or die "$!\n";
while (<FAILED>) {
s/#.*//;
next if /^(\s)*$/;
my $failure = ( split,(/ /, $_) );
$failures{$failure}++;
}
close(FAILED);
foreach $failure ( keys %failures) {
print "The backup of $failure has failed $failures{$failure}
times this month\n";
}
The output I get is this:
The backup of c3duoraint1-bkup /
has failed 2 times this month
The backup of c3duoraint1-bkup /export/home
has failed 2 times this month
The output needs to be on one line ie;
The backup of c3duoraint1-bkup / has failed 2 times this month.
Can someone tell me what I'm doing wrong. I am also getting an error
on the split it says the way I'm using it is deprecated and I'm not
sure what I'm doing wrong there either.
Thanks,
Jesse