Support leaving bars untouched for either aesthetical reasons or to avoid
calculation (which may yet be(come) costly or buggy).
String argument is only checked for emptiness, otherwise all positions are
enabled. Effectively boolean but with future compatibility for more
detailed customisation.
-use Getopt::Long '2.33';
+use Getopt::Long '2.33', qw( :config gnu_getopt );
sub podexit { require Pod::Usage; Pod::Usage::pod2usage(-exitval => 0, @_) }
GetOptions(\my %opt,
'color|c!',
sub podexit { require Pod::Usage; Pod::Usage::pod2usage(-exitval => 0, @_) }
GetOptions(\my %opt,
'color|c!',
'width|w=i',
'usage|h' => sub { podexit() },
'help' => sub { podexit(-verbose => 2) },
'width|w=i',
'usage|h' => sub { podexit() },
'help' => sub { podexit(-verbose => 2) },
my $size = ($maxval - $minval) &&
($opt{width} - $lenval - $len) / ($maxval - $minval); # bar multiplication
my $size = ($maxval - $minval) &&
($opt{width} - $lenval - $len) / ($maxval - $minval); # bar multiplication
-sub orderpos { (($order[$_[0]] + $order[$_[0] + .5]) / 2 - $minval) * $size }
-$barmark[ (sum(@order) / @order - $minval) * $size ] = '='; # average
-$barmark[ orderpos($#order / 2) ] = '+'; # mean
-$barmark[ -$minval * $size ] = '|' if $minval < 0; # zero
-defined and $opt{color} and $_ = "\e[36m$_\e[0m" for @barmark;
+if ($opt{markers} // 1) {
+ sub orderpos { (($order[$_[0]] + $order[$_[0] + .5]) / 2 - $minval) * $size }
+ $barmark[ (sum(@order) / @order - $minval) * $size ] = '='; # average
+ $barmark[ orderpos($#order / 2) ] = '+'; # mean
+ $barmark[ -$minval * $size ] = '|' if $minval < 0; # zero
+ defined and $opt{color} and $_ = "\e[36m$_\e[0m" for @barmark;
+}
for my $nr (0 .. $#lines) {
my $val = $values[$nr];
for my $nr (0 .. $#lines) {
my $val = $values[$nr];
Disable colored output of values and bar markers.
Disable colored output of values and bar markers.
+=item -m, --markers=
+
+Statistical positions to indicate on bars.
+Cannot be customized yet,
+only disabled by providing an empty argument.
+
+Any value enables all marker characters:
+
+=over 2
+
+=item B<=>
+
+Average:
+the sum of all values divided by the number of counted lines.
+
+=item B<+>
+
+Median:
+the middle value or average between middle values.
+
+=back
+
=item -w, --width=<columns>
Override the maximum number of columns to use.
=item -w, --width=<columns>
Override the maximum number of columns to use.