summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-05-06 05:56:00 +0530
committerAndinus <andinus@nand.sh>2020-05-06 05:56:00 +0530
commit5c50bc3b92df1cff7ac0061fcbe0979c6ee61502 (patch)
tree49ac8a308af2f5a7d4d0d2dd2ef53f228c2cdb04
parent9db486d8355a8bee04a31739754a06b06b057f23 (diff)
downloadpictor-5c50bc3b92df1cff7ac0061fcbe0979c6ee61502.tar.gz
Use \t instead of \s & make the output neater
We replace \t with ": " before printing to make the output neater.
Also \t is now used to match against instead of /s because it's what
defined in wtf manual.

Talking about OpenBSD 6.6 wtf manual here, I assume it will be the
same for original wtf.
-rwxr-xr-xpictor.pl8
1 files changed, 5 insertions, 3 deletions
diff --git a/pictor.pl b/pictor.pl
index fc24968..de255ef 100755
--- a/pictor.pl
+++ b/pictor.pl
@@ -53,9 +53,11 @@ foreach my $fn (@files) {
 
     while (my $line = readline $fh) {
 	# \Q is quotemeta, \E terminates it because otherwise it would
-	# mess with \s. This regex matches when $line starts with
-	# "$term\s", \s being any kind of whitespace.
-	print $line if ($line =~ /^\Q${term}\E\s/i);
+	# mess with \t. This regex matches when $line starts with
+	# "$term\t". We replace \t with ": " before printing to make
+	# the input neat.
+	print $line =~ s/\t/: /r if
+	    ($line =~ /^\Q${term}\E\t/i);
     }
 }