Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: get n lines before or after a pattern

by zentara (Archbishop)
on Jul 25, 2012 at 16:28 UTC ( #983697=note: print w/replies, xml ) Need Help??


in reply to get n lines before or after a pattern

Untested, but a useful approach.
#!/usr/bin/perl use strict; use warnings; my @buffer; # a queue data structure while ( <DATA> ) { if ( /I sent/ ) { print @buffer; # 3 lines before print; # the matching line print scalar(<DATA>); # 1 line following last; # all done } push @buffer, $_; shift @buffer if @buffer > 3; } __DATA__ this is the output from the command I sent to the command interperter

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://983697]
help
Chatterbox?
[vedagiri89]: CentOS Linux release 7.0.1406 (Core)
[hippo]: How did you install libapreq2?
[vedagiri89]: that one is done by system team from the tar i guess
[hippo]: Really? Not using the one from the CentOS repository? Perhaps that's the problem.
[vedagiri89]: i need when this issue will come usually
[hippo]: How about mod_perl? Was that installed from the CentOS packge or from source?
[vedagiri89]: from the source
[hippo]: But APR.pm is under vendor_perl in your error message so you are mixing up modules installed from the packager and by hand. That's rarely a good plan.
[vedagiri89]: the prm is..works fine if i run file directly..not working if i run through apache http file

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-06-19 11:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (113 votes). Check out past polls.

    Notices?