my $script; while () { $script .= $_; $script .= qq{print "line $.\\n";\n}; } eval $script; __END__ # your script goes here #### use FollowLines; __DATA__ # your script goes here #### if ($some_var == 1 || $other_var == 2 || $third_var) { sprintf("%s %s %d %s\n", $some_var, $other_var, @rest); }