I have a small perl module, and am using Getopt::Long, and I figured I might as well use Pod::Usage to get a nice looking help display.

After some fiddling, I got it to work reasonably well, with one minor exception. I can't set the width of the output.

My terminal is 191 characters wide. Using perldoc Test.pm, it correctly formats the documentation to that width. Using pod2usage(), it uses the default width of 76 characters.

I can't figure out how to get the width option passed in to the formatter. The documentation shows how to set a different formatter (such as Pod::Text::Termcap) using a BEGIN block, and I used Term::ReadKey to pull the width (verified), but I just can't get the formatter to see it.

Any hints?

package Test; BEGIN { use Term::ReadKey; my ($width, $height, $pixel_width, $pixel_height) = GetTerminalSiz +e(); #print "WIDTH: $width\n"; $Pod::Usage::Formatter = 'Pod::Text::Termcap'; $Pod::Usage::width = $width; } use Pod::Usage; use Pod::Find qw(pod_where); # stuff GetOptionsFromArray( \@args , 'help|?' => sub { pod2usage( -width => $width, -input = +> pod_where( {-inc => 1}, __PACKAGE__), -exitval => 1 ); }, 'man' => sub { pod2usage( -input => pod_where( {-inc + => 1}, __PACKAGE__), -exitval => 2, -verbose => 2 ); }, );

In reply to pod2usage width by quixadhal

Title:
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, details, 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, summary, 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.