SwellJoe has asked for the wisdom of the Perl Monks concerning the following question:
And then using the print method like so:my $log = new File::QuickLog(file => "logtaild.log");
The error I'm getting is this:$log->print("Starting in build mode.");
So I think what is happening is that the $log object no longer (or ever) had some piece of information needed for the open...that seems to make sense, except the information needed should all be there as far as I can tell:(in cleanup) Can't call method "open" on an undefined value at ./logt +aild.pl line 334 during global destruction.
From this I'm thinking we've got _logfile from 'file' during construction, and _fh comes from the Filehandle object, and logstart is just a timestamp created by a small date object included in the log class.my $self = bless { _logfile => $arg{'file'} ? $arg{'file'} : $arg[0], _fh => new FileHandle, _logstart => _datetime(), }, $class;
The line that is complaining is here:
It looks like we're calling open with the filehandle object that we constructed earlier, and the logfile name that was passed to the object constructor.unless($self->{'_fh'}->open (">>".$self->{'_logfile'})){ croak "Failed to open \"".$self->{'_logfile'}."\""; }
The object language/syntax of perl still baffles me, so I suspect my problems are more opaque to me than to someone who understands objects in perl better. If larger code snippets are required, let me know--the full module is linked above, and it is quite simple to understand (even for me, except for some of the object stuff).
Anyway, thanks for any pointers anyone can provide that will set me on the path. I'm running with Use strict and -w, of course...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Objects and undefined values
by chromatic (Archbishop) on Feb 07, 2002 at 20:11 UTC | |
by SwellJoe (Scribe) on Feb 07, 2002 at 20:41 UTC | |
by chromatic (Archbishop) on Feb 07, 2002 at 22:39 UTC | |
by SwellJoe (Scribe) on Feb 08, 2002 at 02:31 UTC | |
by SwellJoe (Scribe) on Feb 07, 2002 at 22:22 UTC |