Skip to content

Commit

Permalink
Adjust relocate.pl to optionally remove the commented indicator line
Browse files Browse the repository at this point in the history
  • Loading branch information
David Christensen committed Nov 2, 2017
1 parent 2925e58 commit 29b7038
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions relocate.pl
Expand Up @@ -9,8 +9,29 @@

=for example
use lib '/home/jon/interchange/lib';
#use lib '~_~INSTALLPRIVLIB~_~';
Original:
#use lib '~_~INSTALLPRIVLIB~_~';
Output:
use lib '/home/jon/interchange/lib';
#use lib '~_~INSTALLPRIVLIB~_~';
=cut

# If the leading comment starts with #- then the output of the original
# commented line will be suppressed.

=for example
Original:
#-use lib '~_~INSTALLPRIVLIB~_~';
Output:
use lib '/home/jon/interchange/lib';
=cut

Expand Down Expand Up @@ -46,7 +67,7 @@ sub doit {
@ARGV = ($input) if $input;
local ($_) = <>;

s{.*\n(#(.*)~_~(\w+)~_~(.*))}{$2 . doit($3) . "$4\n$1"}eg;
s{.*\n(#(-?)(.*)~_~(\w+)~_~(.*))}{$3 . doit($4) . $5 . ($2 ? '' : "\n$1" )}eg;

if ($output) {
open STDOUT, ">$output" or die "Error creating $output: $!\n";
Expand Down

0 comments on commit 29b7038

Please sign in to comment.