Not related to your question, but there's no need to use parentheses on your sub declaration: you're just telling Perl that no arguments are allowed, and by placing the call before the sub Perl can't check what the sub allows anyway.
If you had use warnings; Perl would have told you this:
$ perl -wE'
foo("bar");
sub foo() { 1; }
'
main::foo() called too early to check prototype at -e line 2.
$ perl -wE'
sub foo() { 1; }
foo("bar");
'
Too many arguments for main::foo at -e line 3, near ""bar")"
Execution of -e aborted due to compilation errors.
The way forward always starts with a minimal test.