I wrote this script because I just wanted to automate typing two lines of Perl every time I wrote a small test-case script.

This is dead simple and doesn't really count as 'cool'. However, in the words of the Greek poet Callimachus and E.F. Shumacher, "small is beautiful".

The script simply prints its own top two lines into every new file specified on the command line, unless the file already exists.

Any and all feedback will be welcomed.

#!/usr/bin/env perl use Modern::Perl; while (<@ARGV>) { my $fname = $_; unless (-e $fname) { open my $fh, '>', $fname; say $fh "#!/usr/bin/env perl"; say $fh "use Modern::Perl;\n\n"; say STDOUT "created $fname"; } else { say STDOUT "*** didn't overwrite $fname"; } }

In reply to simple Perl script template by Dumu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.