sub some_function { # do stuff with $_ } my ($word1, $word2) = split /\s+/,<>; &some_function; # $_ is the first line &some_function while (<>); # $_ cycles through rest of file