in reply to Can I tell a sub to take $_ instead of @_ (like some builtins do)
Or some such like that...sub foo { my $arg = @_ ? shift : $_; ... }
or maybe &foo to satisfy use strict;Be very careful about using &foo. That lets foo have access to @_, which might get you in trouble. It's generally better to say foo() or maybe &foo().
Update: The other people who responded have a good point about localizing $_ if you're going to be changing it. But I don't think that's what you were asking for.
|
|---|