in reply to checking output for text

In case you don't want to use the modules (which i recommend you do offcourse). Could add this line in the loop to make it skip the html.
while (1) { ... last if /^$/; }
Since the html header and body are seperated by a blank line.