#!/usr/bin/perl use strict; doStuff(); # no need for & foo(); sub doStuff { # want to read the file as a single string.... local $/; # if you don't set it to anything, it is undefined open TMP, "; # $file since you are putting the whole file into a scalar, not a list close TMP; # do more stuff with that file... } sub foo { ## here i would want to read the file line-by-line open TMP, "; close TMP; }