perlyhead
asked on
how to open several log files
What's the best way of opening several log files to be read, preferably just read all the files in a directory
c:\logfiles\*.log
open(LOG,"<log1.log") or die("Unable to open the log file!\n
while{
log1
....}
without having to name log1, log2, log3, etc..
c:\logfiles\*.log
open(LOG,"<log1.log") or die("Unable to open the log file!\n
while{
log1
....}
without having to name log1, log2, log3, etc..
ASKER
thanks, that works perfectly. one more thing... how do i specify a directory to read from?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
{local @ARGV=<c:/logfiles/*.log>;
while( <> ){
print $_;
}
}
while( <> ){
print $_;
}
}
ASKER
Smashing! If there are no files to be read it doesn't print a message. Is there something like this I can use?:
or die ("unable to open log file")
or die ("unable to open log file")
ASKER
it's ok, i got it, thanks!
unless(open(LOG,$logfile))
warn "can't access $logfile - $!";
next;
}
while(<LOG>) {
# do something
}
close(LOG);
}