Subject: | File::Data - method "search" |
Date: | Thu, 13 Aug 2015 10:22:02 +0100 |
To: | bug-File-Data [...] rt.cpan.org |
From: | Domibay - Hugo <hugo [...] domibay.es> |
Hello,
I used the module "File::Data" to parse log files for certain entries
inditified with a certain date and time.
According to the explication at
http://search.cpan.org/dist/File-Data/lib/File/Data.pm
I built a regular expression to identify the entries.
I expected to get an Array with the Lines matching the regular expression.
I used the deploy:
"
my @addrs = $o_dat->SEARCH('/^(.*\@.*)$/');
"
but I got an Array with a set of "1" in it.
Looking at the Source Code I found that the Perl Code was wrong.
I needs to changed in this way to achieve the expected result:
from:
"
push(@ret, ($line =~ /$search/));
"
to: ->
"
push(@ret, $line) if($line =~ /$search/);
"
I also changed the debug report to correct the wrong indication "failed"
to -> "result"
from:
"
$self->_debug("search($search) failed(@ret) in file($file) lines($i_cnt)");
"
to:
"
$self->_debug("search($search) lines($i_cnt) in file($file) result(@ret)");
"
I hope this helps to benefit the Perl Programmer Community.
For my deploy to search in log files I would wish this Module would be
able to search several files for the same search expressions.
Regards
Hugo