sub get_errors { my $file = $_[0]; my $cont = do { local( @ARGV, $/ ) = $file; <> }; $1; } sub main { local @ARGV = @_; @ARGV = glob '' unless @ARGV; local $/ = "\n\n\n"; [...] while (<>) { if () { $stat{$rtsdir}{'errors'}++; if ($opts{'errors'}) { my $error = get_errors($anotherfile, $case); [...] } next; } [...] } }