Hi,

Thanks for the help :-)

When I call pod2usage(verbose => 2); the terminal is getting stuck. When I
press CTRL+4, it comes out and displays the whole man page. Would you pls
suggest a solution for this issue?

Regards,
Kelvin Philip

On Tue, Dec 23, 2008 at 6:54 PM, Mr. Shawn H. Corey <shawnhco...@magma.ca>wrote:

> On Tue, 2008-12-23 at 13:29 +0530, Kelvin Philip wrote:
> > Hi,
> >
> > Would someone guide me with a simple example for perl documentation using
> > Pod :: Usage?
>
> # Documentation levels
> my $DOC_USAGE = 0;
> my $DOC_HELP  = 1;
> my $DOC_VER   = 2;
> my $DOC_MAN   = 3;
>
> # --------------------------------------
> # Subroutines
>
> # --------------------------------------
> #      Usage: print_documentation( $documentation_level );
> #    Purpose: Print the usage, help, or man documentation.
> #    Returns: Does not return.
> # Parameters: $documentation_level -- how much documentation to display.
> #                                     0 == usage
> #                                     1 == help
> #                                     2 == version
> #                                     other == man
> #
> sub print_documentation {
>  my $level = shift @_;
>
>  # print the usage documentation
>  if( $level == $DOC_USAGE ){
>    pod2usage(
>      -exitval => 2,
>      -verbose => 99,
>      -sections => 'USAGE',
>    );
>  }
>
>  # print the help documentation
>  if( $level == $DOC_HELP ){
>    pod2usage(
>      -exitval => 2,
>      -verbose => 99,
>      -sections => 'NAME|VERSION|USAGE|REQUIRED ARGUMENTS|OPTIONS',
>    );
>  }
>
>  # print the version
>  if( $level == $DOC_VER ){
>    pod2usage(
>      -exitval => 2,
>      -verbose => 99,
>      -sections => 'VERSION',
>    );
>  }
>
>  # print the man documentation
>  pod2usage(
>    -exitval => 2,
>    -verbose => 2,
>  );
> }
>
> # --------------------------------------
> #      Usage: get_cmd_opts();
> #    Purpose: Process the command-line switches.
> #    Returns: none
> # Parameters: none
> #
> sub get_cmd_opts {
>
>  # Check command-line options
>  unless( GetOptions(
>    usage   => sub { print_documentation( $DOC_USAGE ); },
>    help    => sub { print_documentation( $DOC_HELP  ); },
>    version => sub { print_documentation( $DOC_VER   ); },
>    man     => sub { print_documentation( $DOC_MAN   ); },
>  )){
>    print_documentation( $DOC_USAGE );
>  }
>
> }
>
>
> --
> Just my 0.00000002 million dollars worth,
>  Shawn
>
> Believe in the Gods but row away from the rocks.
>  -- ancient Hindu proverb
>
>

Reply via email to