nemesdani has asked for the wisdom of the Perl Monks concerning the following question:
Error message: #Can't locate object method "writeout" via package "IO::File" at fileobj.pl line 25 (line 25 is $testfh->writeout; Writeout is right there, same package. This must be a very basic error but I'm stuck for hours. Your help is appreciated.#!/usr/bin/perl use strict; use warnings; {package MyFilehandler; my $fh; sub openForRead { my $class = shift; my $filename = shift; bless \$filename, $class; open (FH, '<', $filename) or die "could not open file: $!"; $fh = \*FH; } sub writeout { my @lines = <$fh>; print @lines; } } my $testfh = MyFilehandler->openForRead("betvek"); $testfh->writeout;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Yet another Can't locate object method question
by choroba (Cardinal) on Mar 15, 2012 at 20:13 UTC | |
by nemesdani (Friar) on Mar 15, 2012 at 20:20 UTC | |
|
Re: Yet another Can't locate object method question
by Khen1950fx (Canon) on Mar 15, 2012 at 21:49 UTC | |
by GrandFather (Saint) on Mar 16, 2012 at 08:47 UTC | |
by nemesdani (Friar) on Mar 17, 2012 at 06:23 UTC | |
by choroba (Cardinal) on Mar 17, 2012 at 08:07 UTC | |
by nemesdani (Friar) on Mar 17, 2012 at 08:58 UTC |