in reply to code file refactoring to use English module as per PBP
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: junior application developer
by lloder174 (Novice) on Apr 29, 2009 at 22:06 UTC | |
by whakka (Hermit) on Apr 30, 2009 at 01:52 UTC | |
by AnomalousMonk (Archbishop) on Apr 29, 2009 at 23:06 UTC | |
by johngg (Canon) on Apr 30, 2009 at 08:25 UTC |