use IO::File; $opts{-handle} = IO::File->new($opts{-file}) or die $!; $parser->from_handle(%opts); sub from_handle { my $self = shift; my %opts = @_; while (<$opts{-handle}>) { #... and here we're supposed to read from FH } }