Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
#!/usr/bin/perl #--------------------------------------------------------------------- +------- # Copyright (C) 2001-2003 Ed Halley #--------------------------------------------------------------------- +------- =head1 NAME peek - eat lines of standard input; output a one-line preview instead =head1 SYNOPSIS tar jcvf home.tar.bz2 /home | peek =head1 DESCRIPTION The peek process reads line-oriented text from the standard input, and outputs each line atop each other on the standard output. This is use +ful for reducing visual clutter in large list-oriented processing while keeping some visual feedback of the progress. There are a few options to customize the style, but the defaults are usually quite sufficient. =cut #--------------------------------------------------------------------- +-------- use Getopt::Long; use warnings; use strict; my $wide = 79; my $keep = 0; my %options = ( 'wide|width=i' => \$wide, 'keep!' => \$keep, ); GetOptions(%options) or die; $wide = 0 if $wide < 1; #--------------------------------------------------------------------- +-------- $| = 1; while (<>) { chomp; tr{\n\t}{\r }; printf "%-${wide}.${wide}s\r", $_; } print ' 'x$wide, "\r" if not $keep; print "\n" if $keep; exit(0); __END__ #--------------------------------------------------------------------- +-------- =head1 OPTIONS =over 4 =item B<--width>=[integer] Truncates the output lines to the given width, so as to avoid any line wrapping issues. Default is 79 characters wide. =item B<--keep> The final line of output is left visible on the display. =head1 BUGS The --width should default to the current terminal width, if it can be determined. This animation assumes that a carriage return (as opposed to a newline + or linefeed) will not erase the current line, but will return the output cursor to the beginning of the current line. This is a common convent +ion and holds true for many POSIX-styled terminals, but may not work for a +ll output devices. =head1 LICENSE Copyright (C) 2001-2003 Ed Halley <ed@halley.cc> This program is free software; you can redistribute it and/or modify i +t under the same terms as Perl itself. For details on the Perl Artistic License, read the F<http://www.perl.com/language/misc/Artistic.html> page. =cut

In reply to peek - output a one-line preview of stdin by halley

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-04-25 08:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found