You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

35 lines
786 B

  1. #!/usr/bin/perl
  2. # logger.pl: masks long meaningless output with pretty lines of dots
  3. # Details: 1) reads lines from STDIN and echos them on STDOUT,
  4. # 2) print a '.' to STDERR every $N lines.
  5. # 3) print a newline after a sequence of $C dots
  6. use strict;
  7. use warnings;
  8. # make sure all output gets displayed immediately
  9. $| = 1;
  10. # TODO: add -n and -c options w/ zero checks)
  11. # line and column limits
  12. my $N = 10;
  13. my $C = 72;
  14. # current line and column counters
  15. my $n = 0;
  16. my $c = 0;
  17. # read all lines from STDIN
  18. while (<STDIN>)
  19. {
  20. # echo line to output
  21. print STDOUT $_;
  22. # only display progress every Nth step
  23. next unless ++$n % $N;
  24. print STDERR ".";
  25. # wrap at column C to provide fixed-width rows of dots
  26. print STDERR "\n" unless ++$c % $C;
  27. }
  28. print STDERR "\n"