Perl Problems

Status
Not open for further replies.
So I'm trying to write a simple perl script to compile some stats from a bunch of files into one file. So we've got lots of files (file1, file2, file3, etc) which have lots of lines in them, and on 3 of those lines I want the second chunk of data.
---------------------------------------------------------------
Here's what I have:

#!/usr/local/bin/perl
# M.King, 11.15.01, CS493 Research

$search = "MODE";
open(STATS, ">>stat.log") || print "can't open stat.log";

while (<STDIN> ){
open(INPUT,$_);
while ($line=<INPUT> ) {
print STATS "$_";
if($line =~ /$search/) {
@numbers = split(/\s+/, $line);
$number = @numbers[1];
print "$number\n";
print STATS "$number,";
}
}
close(INPUT);
}
close(STATS);
---------------------------------------------------------------
And basically, the line where is just prints:
print "$number\n";
works just as a I want it to, but when I try to print it to the file by appending it, it either rewrites the file, or doesn't write to the file at all. I made sure that the unix permissions were set:
-rwxrwxrwx 1 mhk9j 0 Nov 17 03:56 stat.log

So I'm wondering what am I doing wrong.

Have I mentioned I think Perl is really cool, I just can't get this to work.

Thanks,
Mike
 
Status
Not open for further replies.