in reply to choosing and/or overriding defaults for a sub argument

How about (thank you || operator!)
my ( $self, $file ) = ( $_[0], ( $_[0]->{file} = $_[1] || $_[0]->{file} ) );
Though if you are setting ->{file}, do you really need $file?
my $self = shift; $self->{file} = shift || $self->{file}; # or... $file = $self->{file} = shift || $self->{file};

Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain

Replies are listed 'Best First'.
Re: Re: choosing and/or overriding defaults for a sub argument
by mdillon (Priest) on May 22, 2001 at 00:45 UTC
    even better (i think):
    my $self = shift; $self->{file} = shift if @_; my $file = $self->{file}; # or just leave this out and use $self->{fil +e}