Perl question
Eric Schwartz
schwartz at ll.mit.edu
Wed May 21 16:52:40 EDT 2003
Hello all,
I have a perl programing question, any help you guys could offer would be
greatly appreciated.
I am trying to search an HTML page for specific data. I have bolded the
text that I want to separate. The problem is that the next piece of HTML
after this is for Cyan cartridge. And I want to save BLACK CARTRIDGE:
Estimated pages Remaining: 6798, then after that do the Cyan and so
forth. I don't know how to modify the code you wrote for me, to save Black
Cartridge, then save estimated pages remaining and the number after it,
without confusing it for the "cyan" estimated pages remaining. I hope this
question is not too confusing, as I am new to programing, I appreciate all
your help. Thanks again
Here is an excerpt of the HTML:
<td valign= op"><font face="Arial,Helvetica" size="1">BLACK
CARTRIDGE<br>HP Part Number: HP C9720A</font>
</td>
<td valign= op"><font
face="Arial,Helvetica" size="1">86%<br></font>
</td>
</tr>
<tr>
<td width="10%"><table
border="1" width="100%"><tr><td><img src="images/Empty_Supply_Gif.gif" alt="">
</td></tr></table></td>
<td width="80%"><table
border="1" cellspacing="0" width="100%">
<tr>
<td>
<table border="0" cellspacing="0" width="86%" height="24"
bgcolor="#000000" valign="top">
<tr>
<td> </td>
</tr>
</table>
</td>
</tr>
</table>
</td>
<td width="10%"><table
border="1" width="100%"><tr><td><img src="images/Full_Supply_Gif.gif" alt="">
</td></tr></table></td>
</tr>
</table></td></tr>
<tr><td><table border="0"
bgcolor="#FFFFFF" width="100%" cellpadding="0" cellspacing="0"
summary="This table details consumable supply information">
<tr>
<td width="90%">
<p align="left"><font face="Arial,Helvetica" size="1" color="#000000">
Estimated Pages Remaining:
</font></p>
</td>
<td width="10%">
<p align="right"><font face="Arial,Helvetica" size="1" color="#000000">
6798
</font></p>
</td>
</tr>
----------------------------------------------------------------------------------------------------
Here is a piece of the perl that I am using, and does not seem to be
working. Remember I need to pull all of the bolded stuff in order.
$buffer = get('http://ipaddress);
print "\nHP 4600 PRINTER STATUS\n\n";
($etapagerem) = $buffer
=~ /BLACK CARTRIDGE\s*(?:<.*?>\s*)/s;
print "Estimated Pages Remaining: $etapagerem\n";
Thanks for all your help.
Eric
schwartz at ll.mit.edu
More information about the Discuss
mailing list