Re: string match question

2013-08-21 Thread Rob Dixon
On 21/08/2013 18:32, Natxo Asenjo wrote: hi, thanks all for your advice. I have just used one of your suggested regex to accomplish this task: if ( $text =~ /.*(critical alarm.*?)\./i ) { my $message = $1; print $message, "\n"; } This captures everything starting with critical alarm

Re: string match question

2013-08-21 Thread Natxo Asenjo
l.com > Website: http://www.mattkunzman.com > LinkedIn: http://www.linkedin.com/pub/matthew-kunzman/b/5ba/94a > - > > > From: Natxo Asenjo > To: beginners@perl.org > Se

Re: string match question

2013-08-21 Thread Matthew K
/b/5ba/94a - > > From: Natxo Asenjo >To: beginners@perl.org >Sent: Wednesday, August 21, 2013 11:32 AM >Subject: Re: string match question > > > >*snip* >I agree with Rob

Re: string match question

2013-08-21 Thread Natxo Asenjo
hi, thanks all for your advice. I have just used one of your suggested regex to accomplish this task: if ( $text =~ /.*(critical alarm.*?)\./i ) { my $message = $1; print $message, "\n"; } This captures everything starting with critical alarm until it finds a dot (non greedy). I agree w

Re: string match question

2013-08-20 Thread Rob Dixon
On 20/08/2013 15:02, Natxo Asenjo wrote: hi, for a nagios (monitoring system) check I need to scrape a web site (this is for a network device, a UPS, whatever). This particular device only offers some functionality through a web interface. I am only interested in the text '1 Critical Alarm Pres

Re: string match question

2013-08-20 Thread Shawn H Corey
On Tue, 20 Aug 2013 16:02:50 +0200 Natxo Asenjo wrote: > I am only interested in the text '1 Critical Alarm PresentA site > wiring fault exists'; is it possible to match this is a simple way (in > fact, the text after 'Critical Alarm Present' may vary, it would be > awesome to be able to get that

Re: string match question

2013-08-20 Thread Matthew K
There are a few ways to do it. It's hard without knowing the data. You could do: $text =~ /Critical Alarm Present([^\.]+)./ ? print "$1\n" : print 0; ;  # if they all end with a period $text =~ /Critical Alarm Present(.*)Recent Device Events./s ? print "$1\n" : print 0;  # if Recent Device Event

Re: string match question

2013-08-20 Thread Jim Gibson
On Aug 20, 2013, at 7:02 AM, Natxo Asenjo wrote: > hi, > > for a nagios (monitoring system) check I need to scrape a web site > (this is for a network device, a UPS, whatever). This particular > device only offers some functionality through a web interface. > > I get the content of the site usi