#here $/ is usually a newline (on Unix, at least) { #localize the input record separator and undefine it local $/=undef; #now reading from STDIN yelds the entire contents at once my $whole_file=<>; #do what you like with lexical $whole_file #... } #here $/ is restored back to its original value