in reply to Matching between files in different machine..?
I think using strictures (use warnings; use strict;) would have undoubtedly helped you here, since between them they'd have pointed out that $rules is undefined in the regular expression i.e. in your snippet
should, I think, readif($line=~/^Request:($rules)/i){
if($line=~/^Request:($rule)/i){
Also note that
is better written as ...foreach (@rules ) { $rule = $_;
Moreover, given that the action is the same for every matched rule, I'd modify your snippet to readforeach my $rule (@rules)
use warnings; use strict; use autodie; use File::Tail; local $|++; open FH, "<rules.txt"; my $rules_re = join '|', <FH>; close FH; $name="C:\\users\\Mizo\\desktop\\log.txt; $file=File::Tail->new(name=>$name, maxinterval=>1,interval=>1, adjusta +fter=>1); while (defined($line=$file->read())) { print $line if ($line=~/^Request:($rules_re)/i); }
Update:
Added suggested modifications ,p>
|
|---|