in reply to Re^3: Stupid mistakes I repeatedly make
in thread Stupid mistakes I repeatedly make
I deliberately use shift now, more and more, for two reasons:
- I have a personal coding convention that all methods should begin with "my $self = shift" (or "my $class = shift" for class methods).
- It opens up a place for me to comment on the expected type:
With the "my ($x, $y, $z) = @_" style, I don't have a clean place for those comments, unless I want to break the list on the left across many lines (ick).sub map_names { my $mapping = shift; # hashref of first-last names my $insensitive = shift; # boolean: should uppercase be the same? my @names = @_; # remaining parameters are names ... }
-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.
In Section
Meditations