File: perlpath.pl

package info (click to toggle)
webmin-virtual-server 2.50-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,608 kB
  • ctags: 392
  • sloc: perl: 15,687; makefile: 95; sh: 8
file content (27 lines) | stat: -rw-r--r-- 738 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# perlpath.pl
# This script gets run only from setup.sh in order to replace the
# #!/usr/local/bin/perl line at the start of scripts with the real path to perl

$ppath = $ARGV[0];
if ($ARGV[1] eq "-") {
        @files = <STDIN>;
        chop(@files);
        }
else {
        # Get files from command line
        @files = @ARGV[1..$#ARGV];
        }

foreach $f (@files) {
        open(IN, $f);
        @lines = <IN>;
        close(IN);
        if ($lines[0] =~ /^#!\/\S*perl\S*(.*)/) {
                open(OUT, "> $f");
                print OUT "#!$ppath$1\n";
                for($i=1; $i<@lines; $i++) {
                        print OUT $lines[$i];
                        }
                close(OUT);
                }
        }