Hi
I am migrating a script that reads a file and appends the line on different archives based on the data in the input line.
Old perl version was 5.005 and new one is perl 5.8.3
my problem is I get the file and put it in a variable. open that file for append, write the input line then close the file. this in a loop until the input line finishes.
#!/usr/local/bin/perl
# Pragmas
use warnings;
use strict refs;
use diagnostics;
#require 5.002;
use vars qw($opt_d);
use Getopt::Std;
my $Self = ($0 =~ m|/([^/]*)$|) ? $1 : $0;
... get the input file named $rawlog
open RAWLOG, "<$rawlog"
while (<RAWLOG>) {
my ($p,$day,$mon,$yr,$tz,$iso
) = m|^([^\[]+)\[(\d\d)/(\w\w\
w)/(\d\d\d
\d)[^ ]+ (.\d\d\d\
d)[^/]+/c/(\w\w)|;
my $file = "$iso/$yr$numMon{$mon}$day
-24.c.$iso
.apxlog";
open OUT, ">>$file" or die "$Self: Cannot append to $file\n$!\n";
print OUT $_;
close OUT or warn "$Self: Cannot close $file\n$!\n";
}
close RAWLOG or warn "$Self: Cannot close $rawlog\n$!\n";
}
but I get this in the error screen:
splitcNchk.pl: Cannot close us/20070702-24.c.us.apxlog
splitcNchk.pl: Cannot close kr/20070702-24.c.kr.apxlog
s.pl: Cannot close de/20070702-24.c.de.apxlog
s.pl: Cannot close us/20070702-24.c.us.apxlog
No such file or directory
s.pl: Cannot close ca/20070702-24.c.ca.apxlog
No such file or directory
s.pl: Cannot close ca/20070702-24.c.ca.apxlog
No such file or directory
s.pl: Cannot close us/20070702-24.c.us.apxlog
No such file or directory
s.pl: Cannot close us/20070702-24.c.us.apxlog
No such file or directory
s.pl: Cannot close us/20070702-24.c.us.apxlog
No such file or directory
How can I get rid of this problem? As I understand the "or warn" part will not happen unless close OUT returns FALSE, right?
I tried to put
$1 =1;
but that do not change the behavior of this program...
pls any help will be appreciated
Gabriel
Start Free Trial