Modify HTML Content with Squid

From the info you've provided, it sounds like you might be best served with something like sqirm. It's a specifically designed program to interact with squid via url_rewrite_program and is probably better than re-inventing the wheel with you're own perl/bash script.

If you still want to do it manually, theres this:

http://www.squid-cache.org/Doc/config/url_rewrite_program/