summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-05-10 01:10:34 +0530
committerAndinus <andinus@nand.sh>2020-05-10 01:10:34 +0530
commiteecc64aa47590838bfc532da0bdcca73fc253a67 (patch)
tree48336908f446ee82daac669802261f527abf3a45
parentb1b562d411d8a9e55cbc0dc761cf4a300b6798ec (diff)
downloadpictor-eecc64aa47590838bfc532da0bdcca73fc253a67.tar.gz
Print error message if no match is found
-rwxr-xr-xpictor.pl12
1 files changed, 10 insertions, 2 deletions
diff --git a/pictor.pl b/pictor.pl
index 608c879..f271d9f 100755
--- a/pictor.pl
+++ b/pictor.pl
@@ -47,6 +47,9 @@ unveil() or
 pledge( qw( rpath )) or
     die "Unable to pledge: $!";
 
+# $total_acronyms will hold the total number of acronyms we find.
+my $total_acronyms = 0;
+
 # Search for acronym in every file.
 foreach my $fn (@files) {
     open my $fh, '<', $fn or
@@ -62,11 +65,16 @@ foreach my $fn (@files) {
 	# 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
+	print $line =~ s/\t/: /r and
+	    $total_acronyms++ if
 	    ($line =~ /^\Q${term}\E\t/i);
     }
 }
 
-# drop pledge permissions
+# Print an error message if we don't find any match.
+say STDERR "I don't know what '$term' means!" and
+    exit 1 unless
+    $total_acronyms;
+
 pledge() or
     die "Unable to pledge: $!";