From 9fd9771b55be514d6ac1bbff2b842d969184b7d5 Mon Sep 17 00:00:00 2001 From: Andinus Date: Fri, 21 Aug 2020 14:32:47 +0530 Subject: Check if $ARGV[0] exists before plugging it in $dispatch It would've failed if user just ran `lyra' passing no arguments. --- lyra.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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(); -- cgit 1.4.1-2-gfad0