On Tue, 05 Oct 2004 22:36:45 -0400, Randy W. Sims
<[EMAIL PROTECTED]> wrote:
> On 10/5/2004 10:25 PM, Kevin Old wrote:
> > Hello everyone,
> >
> > I'm parsing a Logwatch report I get daily from my server and have hit
> > a snag.  I'd like to grab everything between the "pam_unix Begin" line
> > and the "pam_unix End" line.
> >
> >  --------------------- pam_unix Begin ------------------------
> > sshd:
> > Invalid Users:
> > Unknown Account: 17 Time(s)
> > Authentication Failures:
> > admin (ym74043.ym.edu.tw ): 4 Time(s)
> > root (ym74043.ym.edu.tw ): 3 Time(s)
> > unknown (ym74043.ym.edu.tw ): 17 Time(s)
> >  ---------------------- pam_unix End -------------------------
> >
> > The code I have is (assuming the entire report is in $body):
> >
> > $body =~ /
> >                 \-+\spam_unix\sBegin\s\-+
> >                 \((.*)\s*\)  #matchline
> >                 \-+\spam_unix\sEnd\s\-+
> >         /sx;
> >
> 
> This is where the .. range operator is useful:
> 
> while (defined( my $line = <INPUT> )) {
>      if ( /-+ pam_unix Begin -+/ .. /-+ pam_unix End -+/ ) {
>          # between beginning and end
>      }
> }
> 
> See `perldoc perlop`, section "Range Operators"

Thanks Randy!  Any ideas what I'm doing wrong when trying to pull the
data out from between the parenthesis?


-- 
Kevin Old
[EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to