| … | |
… | |
| 432 | open FILE, $file || die "Couldn't open $file for reading."; |
432 | open FILE, $file || die "Couldn't open $file for reading."; |
| 433 | my @lines = <FILE>; |
433 | my @lines = <FILE>; |
| 434 | close FILE || die "Couldn't close $file after reading."; |
434 | close FILE || die "Couldn't close $file after reading."; |
| 435 | |
435 | |
| 436 | # fix perl path |
436 | # fix perl path |
| 437 | my $num = 0; |
437 | $lines[0] =~ m/^#!(\S*)/; |
| 438 | $num = $lines[0] =~ s/^#!.*/#!$perlPath/g; # fix #!... line |
438 | if($1 ne $perlPath) { |
| 439 | warn "couldn't fix #! line in $file\n" unless $num; |
439 | $lines[0] =~ s/^#!\S*/#!$perlPath/; |
| 440 | |
|
|
| 441 | # write the file, only if there were changes |
|
|
| 442 | if($num > 0) { |
|
|
| 443 | open FILE, ">$file" || die "Couldn't open $file for writing."; |
440 | open FILE, ">$file" || die "Couldn't open $file for writing."; |
| 444 | print FILE @lines; |
441 | print FILE @lines; |
| 445 | close FILE || die "Couldn't close $file for writing."; |
442 | close FILE || die "Couldn't close $file for writing."; |
| 446 | } |
443 | } |
| 447 | } |
444 | } |