in reply to filehandler stored in hash-ref

thnx alot! also for explaining that its a handle not a handler :)

One last (almost related) thing. I'm using Tie::Hash, so if the programs dies (because it cannot open the file), the DESTROY sub is called:
sub DESTROY { my $self = shift ; if ( $self->{out} && $self->{out}->opened() ) { ... do stuff .... close $self->{out} ; } }
$self->{out} is the filehandle mentioned in my first post. Unfortunatly this generates the following
(in cleanup) Can't locate object method "opened" via package "IO::Hand +le" at modules/MyTH.pm line 29.
So the question is how do I test if a filehandle is open ?

Replies are listed 'Best First'.
Re^2: filehandler stored in hash-ref
by ikegami (Patriarch) on Dec 10, 2009 at 16:26 UTC
    Perhaps you forgot to load IO::Handle...
      thats it!

      But, if I see this
      (in cleanup) Can't locate object method "opened" via package "IO::Hand +le"
      I would say IO::Handle is already loaded, because its already using this package !
        All handles are virtually blessed to IO::Handle
        $ perl -e'STDOUT->autoflush(1)' Can't locate object method "autoflush" via package "IO::Handle" at -e +line 1.
        That doesn't mean the module is loaded:
        $ perl -e'(bless {}, "Foo::Bar")->doit()' Can't locate object method "doit" via package "Foo::Bar" at -e line 1.

        You can bless some reference into a class without the class (package) being loaded.

        my $demo = bless {}, 'I::Just::Made::This::Up'; print "Things in UNIVERSAL:: work.\n" if $demo->isa('I::Just::Made::Th +is::Up'); $demo->opened(); __END__ Things in UNIVERSAL:: work. Can't locate object method "opened" via package "I::Just::Made::This:: +Up"
        thnx kyle and ikegami, new stuff for me again!!