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