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 with Rob Dixon I should be parsing the html, but unfortunately getting it was proving more complicated than this. If this check breaks with a firmware update then we will have to see wat we do then, these things do not get updates so often, fortunately. -- groeten, natxo -- Groeten, natxo On Tue, Aug 20, 2013 at 6:20 PM, Rob Dixon <rob.di...@gmx.com> wrote: > 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 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 easily. Otherwise I am afraid I will >> have to start parsing html with HTML::TableExtract > > > Parsing the HTML is absolutely the right way to do this. It's not that > hard. If you put a sample of the HTML up (perhaps on pastebin?) then > someone will code it for you. Better that way than writing some > unreliable regular expression that may fail one day with a text string > you haven't thought of, or an update to the device firmware. > > Rob > -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/