So, summarizing the other replies: not really.
The reason is that every modern browser includes a javascript interpreter built-in, but no browser (unless you use that unlikely plug-in mentioned above) includes a perl interpreter, and you need your code to be run client-side. javascript supports regular expressions so I suggest you just learn a little javascript.
You will have trouble with the open() call, though. Where do you expect the file to be? On the client's machine? On the server?