Put a script in debug mode in a hurry!
Just type 'dbg myscript.pl' to put it in debug mode! It adds '-d' to the shebang line. It's sister, 'udbg' is nearly the same thing (takes the '-d' away).
Probably could use some golfing, but it's always worked for me...
here's 'dbg'
#!/usr/local/bin/perl
open INFILE, "$ARGV[0]";
@file = <INFILE>;
close INFILE;
$_ = shift @file;
/^#!/ or die "no shebang, file left untouched";
/-d/ and die "file already in debug mode";
s/$/ -d/;
open OUTFILE, ">@ARGV[0]";
print OUTFILE $_;
for (@file) { print OUTFILE $_ }
close OUTFILE;
and it's sister, 'udbg'
#!/usr/local/bin/perl
open INFILE, "$ARGV[0]";
@file = <INFILE>;
close INFILE;
$_ = shift @file;
/-d/ ? s/-d// : die "file not in debug mode, untouched";
open OUTFILE, ">@ARGV[0]";
print OUTFILE $_;
for (@file) { print OUTFILE $_ }
close OUTFILE;