in reply to Re: question about perl
in thread How do I change the shebang line for all perl scripts in a directory
It is true that your script will replace the Perl path within the shebang
string, but it will also replace it if the same string is
anywhere inside the script.
This one should guarantee that the replacement happens only at the beginning of a string. To ensure that the replacement is carried out only once in each script, though, one more check is needed.perl -pi.bak -e 's[^#!/usr/local/bin/perl][#!/usr/bin/perl]' *.pl
which translates roughly intoperl -pi.bak -e 'BEGIN{$c=@ARGV};s[^#!/usr/local/bin/perl][#!/usr/bin/ +perl] && $c-- if $c> @ARGV' *.pl
#!/usr/bin/perl -w -i.bak use strict our $count=@ARGV; while (<>) { if ($count > @ARGV) { s[^#!/usr/local/bin/perl][#!/usr/bin/perl]; $count--; } print; }
In Section
Seekers of Perl Wisdom