#!/usr/bin/perl use strict; use warnings; use List::Util qw/any/; sub foo { ###my $undeclared_variable = "Printing inside foo()\n"; print $undeclared_variable; } sub bar { my $params = {something => 'whatever'}; if (any { $params->{something} eq $_ } qw(some options or whatever)) { print "Printing inside bar()\n"; } } foo(); bar(); #### Global symbol "$undeclared_variable" requires explicit package name (did you forget to declare "my $undeclared_variable"?) at perl_bad_error_msg.pl line 9. Type of arg 1 to List::Util::any must be block or sub {} (not reference constructor) at perl_bad_error_msg.pl line 14, near "qw(some options or whatever)) " Execution of perl_bad_error_msg.pl aborted due to compilation errors.