Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2024-04-25 05:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found