in reply to Re: question about perl
in thread How do I change the shebang line for all perl scripts in a directory
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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: question about perl
by Trimbach (Curate) on Mar 13, 2002 at 13:07 UTC | |
by rnahi (Curate) on Mar 13, 2002 at 14:00 UTC |