File: fix-perl-path.pl

package info (click to toggle)
prcs 1.3.3-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 4,128 kB
  • ctags: 3,354
  • sloc: cpp: 17,486; ansic: 8,132; sh: 4,710; perl: 2,729; lisp: 1,816; tcl: 1,142; lex: 354; makefile: 225; pascal: 85
file content (38 lines) | stat: -rw-r--r-- 917 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl
# File: fix-perl-path.pl
# Description: Fix path for Perl scripts after initial `#!' in Debian systems
# Author: Rafael Laboissiere <rafael@debian.org>
# Created on: 15 Jun 1998 22:03:41 +0200
# Last modified on: Mon Nov 15 01:33:58 CET 1999

die "usage: $0 file\n" if $#ARGV != 0;

open (FILE, "<$ARGV[0]")
  or die "$0: Could not open file $ARGV[0]\n";

$tmpfile = "/tmp/fix-perl-path-$$";
open (TMP, ">$tmpfile")
  or die "$0: Could not open temp file\n";

$debian_perl_path = "/usr/bin/perl";

@tmp = ();
$done = 0;
while (<FILE>) {
  if ((not $done) && /^\#\![ ]*(.*perl.*)\s+(.*)$/ ) {
    print TMP "#! ".$debian_perl_path." $2\n";
    $done = 1;
  }
  else {
    print TMP $_;
  }
} 
close (FILE);
close (TMP);

system ("mv $tmpfile $ARGV[0]") == 0 
  or die "$0: Could not move temp file into $ARGV[0]\n";

system ("chmod ugo+x $ARGV[0]") == 0 
  or die "$0: Could not chmod +x $ARGV[0]\n";