I'm a bit late to the discussion, but here's my general train of thought:

I'm all for code re-use, but just as I don't optimize prematurely, I also don't code for nonexistent future requirements prematurely. So if there is no foreseeable reason to want to re-use the code, I just get on with writing the script. If there is a possible future reason to re-use the code, I'll still just write the script.

Whenever I have a little downtime, I'll go through my ~/bin (which is part of my source code tracked with CVS, and now git, that follows me everywhere), and look for candidates for re-use. I hardly ever find anything, yet I keep adding scripts that I use regularly. When I know something'll get re-used, then I'll break that out into a module.

I don't use any of the App::*-type modules, but that's mainly because I've never found any that were a good fit for me. I'm watching this thread for suggestions, though.

Most of my "personal use" scripts start like this:

use Local::Stuff; # See below my %o = ( help => sub { pod2usage( -verbose => 2 ) }, # ... defaults go here ... ); GetOptions(\%o, qw< help option=s other=i >) or pod2usage(); __END__ =head1 POD Documentation

What is Local::Stuff?

Local::Stuff is a convenience module I wrote. It stays local to my systems, as the name suggests. It uses Import::Into to hack the caller's namespace to enable pragmas like strict, warnings, and autodie, as well as pull in modules I use frequently and import a few helper subs. All of its features are configurable, but I rarely have to do so. Finally, it's actually spelled Local::Shit to dissuade myself from using it in client code. (Edited to clarify Local::Stuff is not a public dist.)

what are the best, most efficient practices for creating a cool library of perl commands to help you get work done faster?

Use something like Module::Starter to create a skeleton for your new module, then add your cool library code to lib/Local/Cool.pm, write some unit tests in t/, and now you have a module that can be installed easily on anything that runs Perl. See perlnewmod for more info.

As for scripts, you already have the right idea. Just throw them in ~/bin (and use some kind of version control like git).


In reply to Re: TIMTOWTDI but how do you use Perl to create CLI scripts? by rjt
in thread TIMTOWTDI but how do you use Perl to create CLI scripts? by nysus

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.