From: Mischa POSLAWSKY Date: Sat, 7 Sep 2019 14:17:35 +0000 (+0200) Subject: prepare regex to match values X-Git-Tag: v1.04~14 X-Git-Url: http://git.shiar.nl/barcat.git/commitdiff_plain/d094762355002198050376023f117542f6a928ce prepare regex to match values Code cleanup, slight speedup. --- 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) {