X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/ecef4e24e8bd7341a477876098312b76dd58a86e..754ddc0faff70513c78277dd2d81c44849b31619:/graph diff --git a/graph b/graph index 8eb0493..307c9e4 100755 --- a/graph +++ b/graph @@ -1,9 +1,10 @@ #!/usr/bin/env perl -use 5.014; +use 5.018; use warnings; use utf8; use List::Util qw( min max sum ); use open qw( :std :utf8 ); +use experimental qw( lexical_subs ); our $VERSION = '1.02'; @@ -17,7 +18,7 @@ GetOptions(\my %opt, 'follow|f:i', 'trim|length|l=i', 'markers|m=s', - 'unclean|u!', + 'unmodified|u!', 'width|w=i', 'usage|h' => sub { podexit() }, 'help' => sub { podexit(-verbose => 2) }, @@ -39,8 +40,8 @@ $SIG{INT} = 'IGNORE'; # continue after assumed eof my (@lines, @values); while (readline) { - chomp; - s/^\h*// unless $opt{unclean}; + s/\r?\n\z//; + s/^\h*// unless $opt{unmodified}; push @values, s/^ ( \h* -? [0-9]* \.? [0-9]+ |)//x && $1; if (defined $opt{trim}) { my $trimpos = abs $opt{trim}; @@ -53,13 +54,13 @@ while (readline) { } push @lines, $_; } -@lines or exit; $SIG{INT} = 'DEFAULT'; sub show_lines { state $nr = 0; +@lines and @lines > $nr or return; my @order = sort { $b <=> $a } grep { length } @values; my $maxval = $order[0]; @@ -185,7 +186,10 @@ or 68% of all entries. =back -=item -u, --unclean +=item -u, --unmodified + +Do not strip leading whitespace. +Keep original value alignment, which may be significant in some programs. =item -w, --width=