From d094762355002198050376023f117542f6a928ce Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Sat, 7 Sep 2019 16:17:35 +0200 Subject: [PATCH] prepare regex to match values Code cleanup, slight speedup. --- barcat | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/barcat b/barcat index 89b110f..05502ea 100755 --- a/barcat +++ b/barcat @@ -68,10 +68,11 @@ my (@lines, @values); my $anchor = !defined $opt{field} ? qr/\A/ : $opt{field} =~ /^[0-9]+$/ ? qr/(?:\S*\h+){$opt{field}}\K/ : $opt{field}; +my $valmatch = qr/$anchor ( \h* -? [0-9]* \.? [0-9]+ |)/x; while (readline) { s/\r?\n\z//; s/^\h*// unless $opt{unmodified}; - push @values, s/$anchor ( \h* -? [0-9]* \.? [0-9]+ |)/\n/x && $1; + push @values, s/$valmatch/\n/ && $1; if (defined $opt{trim}) { my $trimpos = abs $opt{trim}; if ($trimpos <= 1) { -- 2.30.0