use strict; use warnings; use File::Spec::Functions "devnull"; sub bar { open my $fh, "< $_[0]" or die "couldn't open $_[0]: $!"; print while <$fh>; } sub foo { for (@_) { bar(devnull()) } } $. = 0; foo($.);