in reply to Reaped: Script Error
You should 'use warnings' and 'use strict' in your scripts; they'll help you diagnose a lot of problems.
@logfile = split(/ /, <LOGFILE>);
The problem with the above is that it's going to treat the <LOGFILE> filehandle as a scalar - that is, it's going to extract one line from it - which is presumably the cause of many of your problems. Try this:
#!/usr/bin/perl -w use strict; cd "C:\\Documents and Settings\\Alex\\Desktop"; open LOGFILE, "doomlog.txt" or die "doomlog.txt: $!\n"; open LOGWRITE,">explog.txt" or die "explog.txt: $!\n"; my $clipsobt; for my $logfile (<LOGFILE>){ if ($logfile =~ /clip/i) { $clipsobt++ } } print LOGWRITE "You have obtained $clipsobt clips.\n";
Or you can go with a shorter version:
#!/usr/bin/perl -w use strict; cd "C:\\Documents and Settings\\Alex\\Desktop"; open LOGFILE, "doomlog.txt" or die "doomlog.txt: $!\n"; open LOGWRITE,">explog.txt" or die "explog.txt: $!\n"; my $clipsobt = grep /clip/, <LOGFILE>; print LOGWRITE "You have obtained $clipsobt clips.\n";
-- Human history becomes more and more a race between education and catastrophe. -- HG Wells
|
|---|