To expand what ikegami said (it took me a second to see the bug as well; this is a subtle one), perl interprets the bareword main to mean the function you declared as main, not the implicit package of main. This is documented behavior.
You can fix it by adding the postfix double-colon sigil to disambiguate the bareword main as a package name, by moving the declaration of foo to before the declaration of main, or by removing the name collision.
In reply to Re: Class->can() bug or user error
by chromatic
in thread Class->can() bug or user error
by runrig
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |