I have written a Perl subroutine that is supposed to take the name of a month and return a number if it matches, otherwise returning the original argument if not.
sub convert_month_to_number {
my ($input) = @_;
my @month_names = qw/January February March April May June July August September October November December/;
my @month_names_short = qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/;
for (my $i = 0; $i < scalar(@month_names); $i = $i + 1){
print "$month_names[$i]\n";
if ($input == $month_names[$i]{
return $i;
}
}
return $input;
}
}
However, when compiling this in Padre I receive the error:
syntax error at additionalscripts.pl line 16, near "}"
Global symbol "$input" requires explicit package name at additionalscripts.pl li
ne 19.
syntax error at additionalscripts.pl line 20, near "}"
Execution of additionalscripts.pl aborted due to compilation errors.
I'm not exactly sure why this is occurring, considering how I've already declared $input as a global variable up top. Any help would be greatly appreciated. I'm currently using Perl 5.010 on Windows.