Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Re: print line 5 lines previous to comaprison line!

by Adam (Vicar)
on Jun 08, 2001 at 01:47 UTC ( #86772=note: print w/ replies, xml ) Need Help??


in reply to Re: print line 5 lines previous to comaprison line!
in thread print line 5 lines previous to comaprison line!

Nice. One suggestion:

# change: print $buffer[0] if /$pat/; # to: print $buffer[0] if /\Q$pat\E/o;
The \Q and \E presume that $pat is just a string, not a regex. So you would want to escape any special characters (like '.' or '+' ) and the o tells Perl that $pat isn't going to change in the loop, so it won't keep recompiling the pattern.


Comment on Re: Re: print line 5 lines previous to comaprison line!
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://86772]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2015-07-04 04:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls