about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-08-21 14:32:47 +0530
committerAndinus <andinus@nand.sh>2020-08-21 14:32:47 +0530
commit9fd9771b55be514d6ac1bbff2b842d969184b7d5 (patch)
tree31e51e9457c0a24619f63081ad1cb0d280fa2533
parentbc2163c379f0fa2b4b35e0bf6c6e54d243aec53c (diff)
downloadlyra-9fd9771b55be514d6ac1bbff2b842d969184b7d5.tar.gz
Check if $ARGV[0] exists before plugging it in $dispatch
It would've failed if user just ran `lyra' passing no arguments.
-rwxr-xr-xlyra.pl3
1 files changed, 2 insertions, 1 deletions
diff --git a/lyra.pl b/lyra.pl
index 3aad720..a4e17a1 100755
--- a/lyra.pl
+++ b/lyra.pl
@@ -49,7 +49,8 @@ sub random {
     say $fortunes[ rand @fortunes ]; # Print random fortune.
 }
 
-if ( $dispatch{ $ARGV[0] } ) {
+if ( $ARGV[0]
+         and $dispatch{ $ARGV[0] } ) {
     $dispatch{ $ARGV[0] }->();
 } elsif ( scalar @ARGV == 0 ) {
     HelpMessage();