sluap has asked for the wisdom of the Perl Monks concerning the following question:
## module file, MyFile.pm package MyFile; ## Constructor ## sub new { my $self = {}; bless $self; } sub open_file { my $self = shift; open(FH, "textfile") || die "can't open file"; $self->{FH} = \*FH; } sub read_file { my $self = shift; while (defined ($line = <$self->{FH}>)) { print "Line from file is: $line\n" } } 1; ## script file, scrap.pl #!/usr/local/bin/perl -w use MyFile; $my_object = MyFile->new(); $my_object->read_file();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: File handles in an object
by ferrency (Deacon) on Jul 11, 2000 at 21:21 UTC | |
by visnu (Sexton) on Jul 11, 2000 at 23:01 UTC | |
|
Re: File handles in an object
by btrott (Parson) on Jul 11, 2000 at 21:18 UTC | |
|
RE: File handles in an object
by gnat (Beadle) on Jul 12, 2000 at 00:43 UTC | |
|
(chromatic) Re: File handles in an object
by chromatic (Archbishop) on Jul 11, 2000 at 23:04 UTC |