* Uri Guttman <[EMAIL PROTECTED]> [2007-12-09 19:25]:
> * Michael G Schwern <[EMAIL PROTECTED]> writes:
>> sub new {
>> my $class = shift;
>> return bless( [EMAIL PROTECTED], $class );
>> }
>
> my clean version is:
>
> sub new {
> my ( $class, %self ) = @_ ;
> return bless \%self, $class ;
> }
>
> i don't like using shift for args if i can help it.
Personally I *always* use `shift` for the invocant, but
assignment from [EMAIL PROTECTED] for all other parameters in all but a few
rare circumstances. So methods in my code always read something
like this:
sub frobnitz {
my $self = shift;
my ( $foo, $bar, $baz ) = @_;
# ...
}
It’s a nod to the fact that the invocant is not really in the
same class (no pun intended) as the other parameters. Since
`$self` is thus removed from [EMAIL PROTECTED], and is the *only* thing
removed from it, that also makes it natural to write delegative
code:
# ...
$self->get_veeblefitzer()->frobnitz( @_ );
# ...
--
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}
&Just->another->Perl->hack;
#Aristotle Pagaltzis // <http://plasmasturm.org/>