However, when you are reading a log file, with some logs on several lines, the only solution is to parse the text. But here, split comes to the rescue, and you can easily parse.
For instance, if every log is starting with something like '2009/10/21 15:12:01.123 ', and of course if no other line can start with that pattern, here is an easy way :
my $buf="";
{
local $/=undef;
local *FILE;
open(FILE,"<${file}") or die "Couldn't open file: $!";
$buf = ;
close FILE;
}
my @logs=split(/(20[0-9]{2}\/[0-9]{2}\/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}.[0-9]{2} /,$buf);
shift(@logs);
my $nbLogs=scalar(@logs)/2;
This is perhaps not the more refined way to do it, but it does the job, and it does it well.