From efe8f223b69129acecbdfd6093c9c0dff178633c Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Mon, 21 Nov 2022 00:43:23 +0100 Subject: [PATCH] report variables unformatted on trailing # More syntax stolen from exiftool. --- barcat | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/barcat b/barcat index e02ce4e..a86f74f 100755 --- a/barcat +++ b/barcat @@ -365,8 +365,8 @@ sub show_stat { } if (@order) { my $total = sum @order; - my $fmt = '${sum;color(1)} total in ${count} values'; - $fmt .= ' over ${lines} lines' if @order != @lines; + my $fmt = '${sum;color(1)} total in ${count#} values'; + $fmt .= ' over ${lines#} lines' if @order != @lines; $fmt .= " ($_)" for $opt{report} || (); print varfmt($fmt, { sum => $total, @@ -385,9 +385,10 @@ sub varfmt { my ($fmt, $vars) = @_; $fmt =~ s[\$\{( (?: [^{}]++ | \{(?1)\} )+ )\}]{ my ($name, $cmd) = split /\s*;/, $1, 2; + my $format = $name !~ s/\h*\#// && $opt{reformat}; local $_ = $vars->{$name}; if (defined) { - $_ = $opt{'value-format'}->($_) if $opt{reformat}; + $_ = $opt{'value-format'}->($_) if $format; if ($cmd) { eval $cmd; warn "Error in \$$name report: $@" if $@; -- 2.30.0