http://www.perlmonks.org?node_id=151279


in reply to How do I change the shebang line for all perl scripts in a directory

If all your scripts are in one directory, and they all end with (for example) .pl, you can do it in one line from a UNIX shell:

user% perl -pi.bak -e 'BEGIN{undef $/};s[^#\!/usr/local/bin/perl][#\!/usr/bin/perl]' *.pl

One-liners rock!

Gary Blackburn
Trained Killer

Correction: Code enhanced thanks to mahi