When I answer questions here, I often want to see exactly what kind of errors the posted code is going to throw - so I copy it, open a file in 'vi', paste it in, and (following a careful look at it to make sure that it's not going to do anything nasty to me) run it. The additional bits - e.g., adding on a Perl shebang and running 'chmod +x' on the file - are already shortcuts in my 'vi', but I thought that it would be nice to automate this part, at least. I've got "pmedit" linked to an icon on my Gnome toolbar, so all I have to do now is select the code and click the icon. The displayed file will already contain the code that I highlighted.
The following is a Bourne shell script, and requires 'Xdialog'. Please feel free to modify for other OSes and situations. Constructive comments are highly welcomed. :)