fork download
  1. #!/usr/bin/perl
  2. use strict;
  3. use Getopt::Std;
  4.  
  5. my %opts;
  6. getopts 'aAbeEnstTuv', \%opts; # 'u' is ignored
  7.  
  8. my $showline = $opts{b} || $opts{n};
  9. my $reline = $opts{b}? qr/^(?=.)/m: qr/^/m;
  10. my $quotectrl = $opts{v} || $opts{e} || $opts{t} || $opts{A};
  11. my $quotetab = $opts{t} || $opts{T} || $opts{A};
  12. my $showeol = $opts{e} || $opts{E} || $opts{A};
  13. my $singlespace = $opts{s};
  14.  
  15. undef $/;
  16.  
  17. while (<>) {
  18. s/\n\n+/\n\n/g if $singlespace;
  19. if ($showline) {
  20. my $n = 0;
  21. s/$reline/sprintf '%6d ', ++$n/ge;
  22. }
  23. s/$/\$/mg if $showeol;
  24. s/\t/^I/g if $quotetab;
  25. # skip \11 (tab) and \12 (newline)
  26. s/[\0-\10\13-\37\177]/sprintf '^%c', (ord($&)+64)&0177/ge if $quotectrl;
  27. }
  28.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty