package thor; use strict; use Carp; require Exporter; our($VERSION, @ISA, @EXPORT); $VERSION = "0.1"; @ISA = qw(Exporter); @EXPORT = qw(rdw_open); sub rdw_open(*$;@) #need a file handle and a name, but allow more for the 3 arg open... { local *fh = shift; tie \*fh, __PACKAGE__, @_ ; } sub TIEHANDLE { my $class = shift; my $filename = shift; open my $self, $filename or croak "Couldn't open $filename: $!"; bless $self, $class; return $self; } #### #!/usr/bin/perl use thor; rdw_open(FH,"myfile") or die "Couldn't open myfile: $!"; # replaces tie *FH, "thor","myfile"