"I. Oppenheim" wrote: > > I've written a simple C program, that filters the > output of the "man" unix program, to make readable text > out of it. It works like this: man perl | man2txt > perl.txt
If you have man pages then you must be on *nix and if you are on *nix you should use the col program to convert man to txt. man perl | col -b > perl.txt man col > What would be the best way to code this in Perl? > Could anyone "translate" the following code in a native > Perl idiom for me? > > << > /**** man2txt.c *****/ > #include <stdio.h> > > int main (void) { > > char prev = 0, cur = 0 ; > > cur = getchar () ; > while (!feof (stdin)) { > if (cur == 8) { > cur = 0 ; > } else if (prev != 0) { > putchar (prev) ; > } > prev = cur ; > cur = getchar () ; > } > return 0 ; > } The perl translation of the C code (although this is probably not the "best" way) is: #!/usr/bin/perl $/ = \1; while ( <> ) { if ( $_ eq "\010" ) { $_ = "\0"; } elsif ( $prev ne "\0" ) { print $prev; } $prev = $_; } John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]