use MyModule; my $reader = MyModule->new(); ### MyModule opens a file behind the scenes while(my $line = $reader->get_next_line()){ print "here's the next line: $line\n"; } ### stop when we get to the end of the file, obviously