compile regular expression to -f (without /x)
[barcat.git] / barcat
diff --git a/barcat b/barcat
index 3e1980d6aabef20521353281e5c4e0d167a34c3f..6d5610996a00f7b7c614d67a26956ac162fe2ff4 100755 (executable)
--- a/barcat
+++ b/barcat
@@ -18,7 +18,10 @@ GetOptions(\%opt,
        'color|c!',
        'C' => sub { $opt{color} = 0 },
        'field|f=s' => sub {
-               $opt{anchor} = /^[0-9]+$/ ? qr/(?:\S*\h+){$_}\K/ : $_ for $_[1];
+               eval {
+                       local $_ = $_[1];
+                       $opt{anchor} = /^[0-9]+$/ ? qr/(?:\S*\h+){$_}\K/ : qr/$_/;
+               } or die "$@ for option $_[0]\n";
        },
        'human-readable|H!',
        'interval|t:i',