#!/usr/bin/env perl use strict; use warnings; #use diagnostics; use MyPkgDirectory::MyPkg; my $wmode = '>'; my $rmode = '<'; my $filename = "zz_file.txt"; #my $FH_text_W; # this doesn't work, lexical? our $FH_text_W; # can I globalize my filehandle? open($FH_text_W, $wmode, $filename) || die "ERROR: cannot open $filename for writing $!"; print "Debug: Filehandle is: $FH_text_W\n"; &samplewrite(10, "foofoo"); # I don't want to pass in the FH! close ($FH_text_W); #### package MyPkgDirectory::MyPkg; # assumes MyPkgDirectory/MyPkg.pm use strict; use warnings; BEGIN { require Exporter; our $VERSION = 1.00; our @ISA = qw(Exporter); our @EXPORT = qw(samplewrite); } my $FH_text_W = $main::FH_text_W; #my $FH_text_W; sub samplewrite { my ($ver, $sheet) = @_; print "Debug: Version $ver\n"; print "Debug: SHEET $sheet\n"; print $FH_text_W "Version $ver\n"; # Bombs out here print $FH_text_W "SHEET $sheet\n"; # and here too } END { } 1;