in reply to unable to open input file

Perhaps if you added $! to your error message and printed, erm, what the actual error is it might be enlightening . . .

Tangentally: And you're possibly flirting with disaster not using an HTML parser rather than regexen but if this is a relatively static set of source documents you might can get away with it.

The cake is a lie.
The cake is a lie.
The cake is a lie.