in reply to choosing and/or overriding defaults for a sub argument
Maybe what you want is for the call in the program to obj->file("Filename"); to store the filename internally, and my $fn = obj->file(); to return it.
If so, your code needs to look more like :
to get the file back to the caller.sub filename { my ($self, $file) = @_; $self->{file} = $file if $file; return $self->{file}; }
I don't like the $self->{'file'} = shift || $self->{'file'}; idea, since setting something to itself when you don't need to is less clear.
--
Brovnik
|
|---|