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

Your code is fine, but you can try this if you want:
my ($self, $file) = ($_[0],$_[0]->{file}||=$_[1]);


The 15 year old, freshman programmer,
Stephen Rawls

Replies are listed 'Best First'.
Re: Re: choosing and/or overriding defaults for a sub argument
by arturo (Vicar) on May 22, 2001 at 03:10 UTC

    Unfortunately, that only sets $file to the second argument passed if $self->{file} isn't already set (to a true value, but I assume any filename passed will evaluate to true), which doesn't seem to be what princepawn wants (which is to set $file to be the second value passed if passed, or to be the value of $self->{file} otherwise).