in reply to Re: Why this simple code doesn't work?
in thread Why this simple code doesn't work?
Don't call your subroutines with a prepended "&". It is "old style" dating back to Perl 4! The effect of it now is that any prototypes are ignored. In the few cases they are actually usefully used, you surely do not want to do that and in all other cases it saves you one character less to type.
Yeah, except in this case, things will break.
Please, think before giving Pavlov reactions. Don't trigger a standard response to seeing a &sub. The use of &read is completely justified in this case, and your suggestion will break the construct. And not because of the prototype.
Besides, there's no need to look down on constructs that predate Perl5. Regular expressions are "perl4" (actually, older than that). Many keywords are from the pre-perl5 era. And it's kind of silly to first say "don't use prototypes - in fact, try to forget they exist" and then "don't use &sub, because that bypasses prototypes".