#!/usr/bin/perl use strict; use warnings; {package MyFilehandler; my $fh; sub openForRead { my $class = shift; my $filename = shift; bless \$filename, $class; open (FH, '<', $filename) or die "could not open file: $!"; $fh = \*FH; } sub writeout { my @lines = <$fh>; print @lines; } } my $testfh = MyFilehandler->openForRead("betvek"); $testfh->writeout;