use strict; use warnings; use Test::More tests => 4; open (F, "echo -e 'a\nb\nc'|"); my $line = ; is ($line, "a\n", "a in main()"); while ($line) { if ($line =~ /a/) { SubOut (\*F); } ok (eof (F), "F is exhausted"); $line = ; } close (F); sub SubOut { my $fh = shift; my $s_line = <$fh>; while ($s_line) { like ($s_line, qr/[bc]\n$/, "b or c matched in SubOut()"); $s_line = <$fh>; } }