August 1999 Return to the Perl Hardware Store Slide #12

Globjects

        package IO::Remembers;  
        sub new {
          my ($pack, $filename) = @_;
          my $fh = \do { local *FH };     # Incantation
          open $fh, $filename or return; 
          bless $fh => $pack;
        }
        my $fh = new IO::Remembers ('input');
        my $line = <$fh>;
        read $fh, $bytes, 1024;
        print $fh "Actually this filehandle was opened for reading only...\n";
        close $fh;


Next Copyright © 1999 M-J. Dominus