in reply to Wrong regex?
#OUTPUT:#!/usr/local/bin/perl use strict; use warnings; print "IP\t\tStatus\n"; print "-" x 25; print "\n"; while(<DATA>){ chomp; next unless $_ =~ /^<\/HEAD>.*/i; #skip un-interestin +g lines. #my ($ip, $status) = $_=~ m/(\d+\.\d+\.\d+\.\d+)\s+:\s+( +\w+)/; my ($ip, $status) = $_=~ m/([0-9\.]+)\s+:\s+(\w+)/; print "$ip\t $status\n"; } __DATA__ </HEAD><BODY><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"><H2>Set Node + to Monitored <BR> 10.10.10.10 : Minor </H2><FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded"> </HEAD><BODY><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"><H2>Set Node + to Monitored <BR> 10.10.10.9 : Major </H2><FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded"> </HEAD><BODY><META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE"><H2>Set Node + to Monitored <BR> 10.10.10.1 : Major </H2><FORM METHOD="POST" ENCTYPE="application/x-www-form-urlencoded">
IP Status ------------------------- 10.10.10.10 Minor 10.10.10.9 Major 10.10.10.1 Major
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Wrong regex?
by graff (Chancellor) on Feb 10, 2010 at 18:28 UTC |