Some of the responses thus far won't properly handle a filename that evaluates to false (filename is '0' perhaps). Since you are using $self may I assume you are writing an object method? If so, perhaps you want to provide a get/set method to the file attribute and just call that appropriately within your other method:
sub whatever { my $self = shift; my $file = $self->file(@_); # ... do stuff } sub file { my $self = shift; $self->{file} = shift if @_; $self->{file}; }
In reply to Re: choosing and/or overriding defaults for a sub argument
by danger
in thread choosing and/or overriding defaults for a sub argument
by princepawn
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |