in reply to Can I tell a sub to take $_ instead of @_ (like some builtins do)

You can easily write a sub so that it uses $_ if it gets no other arguments.
sub foo { my $arg = @_ ? shift : $_; ... }
Or some such like that...
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.

  • Comment on Re: Can I tell a sub to take $_ instead of @_ (like some builtins do)
  • Download Code