http://www.perlmonks.org?node_id=805706


in reply to style guidance

Not a huge fan of $_ here, I like named things. While it's neither difficult nor tricky to remember to use 'local $_ = shift;', it feels like a contrived and hoop-jumpish thing to do to avoid using a variable later. Just call it something. When there are multiple arguments, I like how the multiple shift style scales, easy to change the order, insert, delete and comment:
sub do_stuff { my $foo = shift; my $bar = shift; ... }
See What's so bad about &function(...)? for the style discussion about do_stuff(1, 2, 3) vs. &do_stuff(1, 2, 3).

YuckStyle

Replies are listed 'Best First'.
Re^2: style guidance
by dsheroh (Monsignor) on Nov 08, 2009 at 12:55 UTC
    Agreed.

    This question brings to mind chromatic's recent blog post on The Act of Naming. Granted, his post is about subroutine names and why you might want to create technically-superfluous subs purely for the sake of being able to name sections of your code, but the reasoning seems applicable to variables as well: Creating a new (lexical) variable with a good name is cheap, safe, and easy - cheaper and easier than the contortions demonstrated by some of the other responses' attempts to keep assigning to $_ safe - and it also helps to convey what your code is actually intended to accomplish. So JFDI.