note Aristotle <p>I have to agree with the others &mdash; this is far too convoluted and too seldomly useful to be a reasonable idiom. If you must, I'd at least replace the [perlfunc:shift|shift] with a simple <tt>$_&#91;0]</tt> so what's going on is just a little more obvious. I still don't like it one bit, though. If you don't have any positional parameters, why are you passing an anonymous hash? If you don't, it's easy to make the happenings blindingly obvious at the cost of one extra line:</p> <code> sub foobar { my %arg = @_; my ($foo, $bar) = @arg{qw/ -foo -bar /}; # .. } </code> <p>Even if you have positional parameters, an easy solution is to put them at the beginning of the list so that you can say something like</p> <code> my ($foo, $bar, %arg) = @_; my ($baz, $quux) = @arg{qw(baz quux)}; </code> <p>The one case a hashref makes sense is in case of a method called on a hash-based class.</p> <p>But then your "idiom" means throwing away <code>$self</code>, which I'd consider a bad idea. Even if the particular method's code is sufficiently simple to allow for this, it makes a future change in requirements that requires a calling a method on <tt>$self</tt> more difficult.</p> <p>More importantly, I use <code>my $self = shift;</code> as a form of self documentation in the code. Helper non-method functions included in a package do not have this, so you can see at a glance what is a function and what is a method. And in that case this "idiom" is completely redundant:</p> <code> sub moo { my $self = shift; my ($foo, $bar) = @$self{qw(foo bar)}; # .. } </code> <div class="pmsig pmsig-114691"> <p align="right"><em>Makeshifts last the longest.</em></p> </div> 332886 332886