in reply to Yet another Can't locate object method question

You constructor (openForRead) returns the last expression evaluated, $fh. But this is an object of a different class - IO::File. You blessed \$filename to your class, not the handle, and you did not return it.

Moreover, $fh is declared with my in the package. Why? Do you want to keep the same file handle for all the instances of the class? Just create a fresh new reference in the constructor and use idiomatic my $self = shift; in other methods.

Replies are listed 'Best First'.
Re^2: Yet another Can't locate object method question
by nemesdani (Friar) on Mar 15, 2012 at 20:20 UTC
    Thank you very much! As for the $fh: silly mistake, I simply have to get accustomed to classes and instances. Thanks again.