Changing shebangs should be no problem for an abbot.
#! /usr/bin/perl
use strict;
use warnings;
use File::Find;
File::Find->find(&main::wanted, '/');
sub wanted {
if (-T $File::Find::name) {
open ("FILE", "< $File::Find::name")
or die ("$!: Could not open " . $File::Find::name);
my $first_line = <FILE>";
unless ($first_line =~ m(^\#\!\s{0,1}/usr/bin/perl\n$) {
return 0;
}
$first_line =~ s[perl][perl5]i;
while (<FILE>) {
$first_line .= $_;
}
close ("FILE")
or die ("Could not close file "
. $File::Find::name
. " because $!");
# create a temp file so if we get interrupted
# we won't lose our data
`cp $File::Find::name $File::Find::name~`;
open ("FILE", "> $File::Find::name")
or die("Can't open $File::Find::name for "
. "writing because $!");
print FILE $first_line;
close ("FILE")
or die ("Cannot close $File::Find::name "
. "because $!");
# get rid of the temp file
unlink ("$File::Find::name~");
}
}
Want to support the EFF and FSF by buying cool stuff? Click
here.