in reply to Re^2: (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.
in thread (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.
If you just want to fix that line, you can do it like this:
sub DESTROY { my $class = shift; return if ${^GLOBAL_PHASE} eq 'DESTRUCT'; $class->{handle}->close() if defined $class->{handle}; }
However, as mentioned elsewhere, $class->{handle} is *only* used in your destructor, so it's not really a useful line of code. Then, going backwards through the destructor, there's nothing happening that needs to be done. So removing the destructor would be the correct solution. But since you said it's a sample of your code, you might've removed a subroutine or two that could potentially set the handle member. In that case, this change should clear things up for you.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: (in cleanup) Can't call method "close" on an undefined value at somePerlModule.pm line number.
by thanos1983 (Parson) on Jan 30, 2015 at 22:38 UTC | |
by BrowserUk (Patriarch) on Feb 01, 2015 at 17:05 UTC | |
by Anonymous Monk on Feb 01, 2015 at 20:06 UTC | |
by BrowserUk (Patriarch) on Feb 01, 2015 at 21:36 UTC | |
by ikegami (Patriarch) on Feb 02, 2015 at 15:46 UTC | |
by roboticus (Chancellor) on Feb 01, 2015 at 16:51 UTC |