rapide has asked for the wisdom of the Perl Monks concerning the following question:

This is probably asked before but I could not find any answer for it.

I have a longer text in my script that is in POD-format. When user types '--manual' I want to display this manual to the user with 'less'. Is this possible without storing it to files first?

if($ARGV[0] eq '--manual') { < PRINT MAN PAGE FROM FUNCTION BELOW > } sub Documentation () { return " =pod =head1 B<NAME> perlmonc - This is my program =cut " }

Replies are listed 'Best First'.
Re: Displaying in-line POD as man-pages 'on-the-fly'
by FunkyMonk (Bishop) on Sep 07, 2008 at 19:02 UTC
Re: Displaying in-line POD as man-pages 'on-the-fly'
by shmem (Chancellor) on Sep 07, 2008 at 19:06 UTC

    See Getopt::Long. From its pod:

    Getopt::Long encourages the use of Pod::Usage to produce help messages +. For example: use Getopt::Long; use Pod::Usage; my $man = 0; my $help = 0; GetOptions('help|?' => \$help, man => \$man) or pod2usage(2); pod2usage(1) if $help; pod2usage(-exitstatus => 0, -verbose => 2) if $man; __END__ =head1 NAME sample - Using Getopt::Long and Pod::Usage =head1 SYNOPSIS ...
      Great answer! Very easy to use! :-)

      pod2usage(-exitstatus => 0, -verbose => 2, -input => 'docu.pod');

Re: Displaying in-line POD as man-pages 'on-the-fly'
by jwkrahn (Abbot) on Sep 07, 2008 at 20:05 UTC

    Or you could do it this way:

    if ( $ARGV[ 0 ] eq '--manual' ) { 0 == system 'perldoc', $0 or die $?; } __END__ =pod =head1 B<NAME> perlmonc - This is my program =cut