Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I've written a program which is distributed as a single script, but implemented as a series of modules. Distributing the script as one file avoids the need to "install", or mess with include-paths.

Unfortunately this means that my script looks like this:

# ... pod for module1 # ... code for module1 # ... POD for module2 # .... code for module2 # package main # pod # code

This screws up my preferred usage of POd::Usage, as it shows the pod for all the script. I've read the documentation for Pod::Usage, where it suggets using Pod::Find and the current package (__PACKAGE__) but I cannot make it work, as the following demonstrates.

Is there a simple solution, or am I out of luck?

Test program follows:

#!/usr/bin/perl -w use strict; use warnings; use Getopt::Long; use Pod::Find qw(pod_where); use Pod::Usage; =head1 NAME Foo - Do something. =cut =head1 SYNOPSIS use strict; use Foo; my $f = Foo->new(); $f->doStuff(); =cut =head1 DESCRIPTION This class encapsulates stuff. =cut package Foo; =head2 new Constructor =cut sub new() { my ( $proto, %supplied ) = (@_); my $class = ref($proto) || $proto; my $self = {}; bless( $self, $class ); return $self; } =begin doc Do stuff =end doc =cut sub do_stuff() { } =head1 NAME My Script - Do something =cut =head1 SYNOPSIS Usage: $0 [options] options --help Show the help --man Show the manual. =cut =head1 DESCRIPTION This is the utility to do stuff .. It uses the Foo module internally. =cut package main; # # Configuration variables # my %CONFIG; # # Parse the command line. # exit if ( !Getopt::Long::GetOptions( # Help options "help", \$CONFIG{ 'help' }, "manual", \$CONFIG{ 'manual' }, ) ); Pod::Usage::pod2usage() if ( $CONFIG{ 'help' } ); Pod::Usage::pod2usage(-verbose => 2 ) if ( $CONFIG{ 'manual' } ); print "I am alive\n"; exit( 0 );

In reply to Showing the right POD via Pod::Usage by skx

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 perusing the Monastery: (4)
    As of 2021-04-17 13:56 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found