Subject: | Use the 'run' sub with a filename as parameter |
Shell-Source-0.01
Hello,
I just take a look at this module (after reading about it on http://www.tek-tips.com/viewthread.cfm?qid=974317&page=1) and I have one question.
In the 'run' sub below, you do not seem to use the $file variable set at the second line: you always use $self->{file}.
It seems to me that this 'run' routine could be use with a file name as parameter if the file name is not given in the 'new', but I do not think this work in this version.
OK, this 'run' sub is not documented in the interface (only the 'new' sub) but as it does not start with a _ (underscore) ...
Am I missing something ?
Denis Choulette.
sub run
{
my $self = shift;
my $file = shift || $self->{file};
croak "Must specify file to source" unless length $self->{file};
(my $run = $self->{run}) =~ s/\[\[file\]\]/$self->{file}/g;
my $fh = $self->{fh}
= FileHandle->new($run) or croak "Can't run $self->{shell}";
$self->_parse;
$fh->close or croak "Can't close $self->{shell}";
$self
}