in reply to simple Perl script template

Dumu:

You may want to compare line 8 with line 1 and make appropriate changes.... ;^D

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: simple Perl script template
by afoken (Chancellor) on Apr 09, 2015 at 11:33 UTC
    You may want to compare line 8 with line 1 and make appropriate changes....

    ... or use $^X.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

      Or just print the first two lines of the script itself in order to avoid inconsistencies:

      #!/usr/bin/env perl use Modern::Perl; seek DATA, 0, 0; my $header = join '', (<DATA>)[0..1]; for my $fname (@ARGV) { unless (-e $fname) { open my $fh, '>', $fname; print $fh $header; say STDOUT "created $fname"; } else { say STDOUT "*** didn't overwrite $fname"; } } __DATA__
        I like the idea of using the script actually copying from itself to the new script templates. This is DRYer. I have updated my local copy to this.
Re^2: simple Perl script template
by Dumu (Monk) on Apr 09, 2015 at 12:34 UTC
    Thanks roboticus. I have updated the script from :
    say $fh "#!/usr/bin/perl env";
    to:
    say $fh "#!/usr/bin/env perl";
    8^)