I'm not sure that there is a 'p' modifier for regular expressions (did you mean to use the '-p' command-line switch?) and there is no point in using the 'x' modifier if you don't use extended syntax. This can be done in a one-liner like this.
$ mkdir lloderl74 $ cat > lloderl74/script1 #!/usr/bin/perl -w print "Hello World!\n"; exit; $ cat > lloderl74/script2 #!/usr/bin/perl -w die "Goodbye, Cruel World\n"; $ perl -pi.bak -e ' s{^(#!/usr/bin/perl.*)}{$1\n\nuse English q{no_match_vars}}' lloderl74 +/* $ head -99 lloderl74/* ==> lloderl74/script1 <== #!/usr/bin/perl -w use English q{no_match_vars} print "Hello World!\n"; exit; ==> lloderl74/script1.bak <== #!/usr/bin/perl -w print "Hello World!\n"; exit; ==> lloderl74/script2 <== #!/usr/bin/perl -w use English q{no_match_vars} die "Goodbye, Cruel World\n"; ==> lloderl74/script2.bak <== #!/usr/bin/perl -w die "Goodbye, Cruel World\n";
I hope this helps you.
Cheers,
JohnGG
In reply to Re: junior application developer
by johngg
in thread code file refactoring to use English module as per PBP
by lloder174
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |