Can "perldoc" take input from a pipe?

Discussion in 'Perl Misc' started by jomarbueyes@hotmail.com, Apr 15, 2008.

  1. Guest

    Dear All,

    Is there a way to make perldoc take its input from stdin? I tried the
    obvious:
    command | perldoc
    but it didn't work.

    My idea is to embed "pod" documentation in source code written in
    Fortran and C++, then write a perl script that will search for the pod
    documentation, remove the comment marks, and pipe the resulting output
    to something that can format perlpod.

    I'm using Perl 5.8.8 under Linix and Mac OS X (10.5 Intel and 10.4
    PPC) and Perl 5.004_05 under Irix 6.4.

    Thanks in advance for any help,

    Jomar
     
    , Apr 15, 2008
    #1
    1. Advertising

  2. Guest

    On Apr 15, 12:28 pm, Frank Seitz <> wrote:
    > wrote:
    >
    > > Is there a way to make perldoc take its input from stdin? I tried the
    > > obvious:
    > > command | perldoc
    > > but it didn't work.

    >
    > > My idea is to embed "pod" documentation in source code written in
    > > Fortran and C++, then write a perl script that will search for the pod
    > > documentation, remove the comment marks, and pipe the resulting output
    > > to something that can format perlpod.

    >
    > I would use the pod2man-converter which reads from stdin.
    >
    > $ command | pod2man | less
    >
    > Frank
    > --
    > Dipl.-Inform. Frank Seitz;http://www.fseitz.de/
    > Anwendungen für Ihr Internet und Intranet
    > Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel


    Thanks Frank,

    I added a pipe to "nroff -man", i.e
    $ command | pod2man | nroff -man | less
    and that does what I needed.

    Thank you again,

    Jomar
     
    , Apr 15, 2008
    #2
    1. Advertising

  3. Ben Morrow Guest

    Quoth :
    >
    > Is there a way to make perldoc take its input from stdin? I tried the
    > obvious:
    > command | perldoc
    > but it didn't work.
    >
    > My idea is to embed "pod" documentation in source code written in
    > Fortran and C++, then write a perl script that will search for the pod
    > documentation, remove the comment marks, and pipe the resulting output
    > to something that can format perlpod.


    perldoc already has that functionality. If I put

    #include <stdio.h>

    /*

    =head1 NAME

    fubar - a program for making mistakes

    =cut

    */

    int
    main (int argc, char **argv)
    {
    return 1;
    }

    into fubar.c (note that all the blank lines inside the comment are
    required, to make it valid POD) then `perldoc fubar.c` quite happily
    formats and displays the POD.

    The real trick, of course, is to work out how to embed it into the
    resulting executable... :)

    Ben
     
    Ben Morrow, Apr 15, 2008
    #3
  4. Guest

    On Apr 15, 1:29 pm, Ben Morrow <> wrote:
    > Quoth :
    >
    >
    >
    > > Is there a way to make perldoc take its input from stdin? I tried the
    > > obvious:
    > > command | perldoc
    > > but it didn't work.

    >
    > > My idea is to embed "pod" documentation in source code written in
    > > Fortran and C++, then write a perl script that will search for the pod
    > > documentation, remove the comment marks, and pipe the resulting output
    > > to something that can format perlpod.

    >
    > perldoc already has that functionality. If I put
    >
    > #include <stdio.h>
    >
    > /*
    >
    > =head1 NAME
    >
    > fubar - a program for making mistakes
    >
    > =cut
    >
    > */
    >
    > int
    > main (int argc, char **argv)
    > {
    > return 1;
    > }
    >
    > into fubar.c (note that all the blank lines inside the comment are
    > required, to make it valid POD) then `perldoc fubar.c` quite happily
    > formats and displays the POD.
    >
    > The real trick, of course, is to work out how to embed it into the
    > resulting executable... :)
    >
    > Ben


    Hi Ben,

    Thank you for your suggestion. It does work with C programs and that
    simplifies things a lot! However, in Fortran there are no block
    comments. Each comment line must have a mark -a "C" in the first
    column in Fortran 77, a bang (!) anywhere before the comment in
    Fortran 90/95/2003. However, it is trivial to remove the bang or "C"
    using a perl script. The output can be piped to pod2man as Frank
    suggested.

    Thanks again for your suggestion,

    Jomar
     
    , Apr 15, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lee, wonsun
    Replies:
    1
    Views:
    505
    Jack Klein
    Nov 2, 2004
  2. learner1020
    Replies:
    4
    Views:
    398
    BGB / cr88192
    Sep 2, 2010
  3. Ronald Fischer

    perldoc can't display doc

    Ronald Fischer, Sep 8, 2003, in forum: Perl Misc
    Replies:
    4
    Views:
    136
    Ronald Fischer
    Sep 9, 2003
  4. Replies:
    1
    Views:
    249
    Ben Morrow
    Jun 2, 2004
  5. jkstill

    Perldoc and the pipe "|" character

    jkstill, Aug 20, 2007, in forum: Perl Misc
    Replies:
    4
    Views:
    146
    jkstill
    Aug 22, 2007
Loading...

Share This Page