in reply to checking output for text
Wow, this is a great script. If I were you, I would assign those regex to variables so you could expand your script to do a little logic. But I'm not exactly sure what you want to do with this...
There isn't anything in the Snippets section quite like this (most likely because it would be simple to implement in LWP), but it could help a struggling beginner (like myself).