Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Hello perlanswers and welcome to the monastery and to wonderful world of Perl!

There are many way to do it but I found the following particulary useful and versatile: The Dynamic Duo --or-- Holy Getopt::Long, Pod::UsageMan!

Infact Pod::Usage can semplfy a lot such part of a program: it can shows sections of your choice of the POD embed in the program (I'm used to put the POD after the __DATA__ token), it has the ability to modify the exit value with the useful NOEXIT feature.

The module can semplify a lot the help and manual commandline options; let's see it's recommendend usage:

use strict; use Pod::Usage; use Getopt::Long; ## Parse options my %opt; GetOptions(\%opt, "help|?", "man", "flag1") || pod2usage(2); pod2usage(1) if ($opt{help}); pod2usage(-exitval => 0, -verbose => 2) if ($opt{man}); ## Check for too many filenames pod2usage("$0: Too many files given.\n") if (@ARGV > 1);


There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: how to write script usage sub routine for the perl file? the dynamic duo with Pod::Usage by Discipulus
in thread how to write script usage sub routine for the perl file? by perlanswers

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, 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, 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.
  • Log In?

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

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (5)
    As of 2021-04-20 05:15 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found