in reply to Re^2: Cable modem status
in thread Cable modem status
well, the conventional wisdom is use a module to parse HTML and I was tempted to make that comment first time around. However the regex seemed sufficiently trivial that it didn't seem really to matter. Using something like HTML::TreeBuilder would sure make it easier to dig the data out for a lot of modems though - mine (which uses a table) for a start!
If you are going to use /x then take advantage of it and use some white space to break up the different components of the regex so they are easier to parse by eye. Consider:
$content =~ m{ Frequency(\d+\s Hz)\s Signal \s To \s Noise \s Ratio([\d.]+ \s dB)\s Power \s Level([\d.-]+ \s dBmV) }xi or My_Die('content failed!');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Cable modem status
by ruzam (Curate) on Feb 17, 2007 at 03:46 UTC |