Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Can "perldoc" take input from a pipe?

Reply
Thread Tools

Can "perldoc" take input from a pipe?

 
 
jomarbueyes@hotmail.com
Guest
Posts: n/a
 
      04-15-2008
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
 
Reply With Quote
 
 
 
 
jomarbueyes@hotmail.com
Guest
Posts: n/a
 
      04-15-2008
On Apr 15, 12:28 pm, Frank Seitz <(E-Mail Removed)> wrote:
> (E-Mail Removed) 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
 
Reply With Quote
 
 
 
 
Ben Morrow
Guest
Posts: n/a
 
      04-15-2008

Quoth http://www.velocityreviews.com/forums/(E-Mail Removed):
>
> 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

 
Reply With Quote
 
jomarbueyes@hotmail.com
Guest
Posts: n/a
 
      04-15-2008
On Apr 15, 1:29 pm, Ben Morrow <(E-Mail Removed)> wrote:
> Quoth (E-Mail Removed):
>
>
>
> > 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there a command that can take a C source code as input and outputa token tree learner1020 C Programming 4 09-02-2010 09:27 PM
When someone can't take good photos they try to take control Nomen Nescio Digital Photography 0 03-04-2009 02:40 PM
Do I have to take 292 & 296 can I take the 4 cores instead? =?Utf-8?B?SmltIEhvbGxvd2F5?= Microsoft Certification 6 06-02-2007 02:12 AM
Take a slow ride....take it eeee-zy ellis_jay Computer Support 0 08-25-2005 01:31 AM



Advertisments