use strict; use warnings; package MyPackage; sub open_file { local *fh; my $ok; # Support both 2 and 3 arg version of open. if (@_ == 1) { $ok = open(*fh, $_[0]); } else { require 5.006; # Require Perl 5.6 $ok = open(*fh, $_[0], $_[1]); } die("$!\n") unless $ok; return *fh; } 1;