1use strict; 2use FileHandle::Unget; 3use File::Spec::Functions qw(:ALL); 4use Test::More tests => 2; 5use Config; 6use File::Temp; 7 8my $path_to_perl = $Config{perlpath}; 9 10TODO: 11{ 12 if ($^O eq 'Win32') 13 { 14 if (require Win32) 15 { 16 local $TODO = 'This test is known to fail on your version of Windows' 17 unless Win32::GetOSName() eq 'Win2000'; 18 } 19 else 20 { 21 local $TODO = 'This test may fail on your version of Windows' 22 } 23 } 24 25 my $tmp = File::Temp->new(); 26 27 { 28 binmode $tmp; 29 print $tmp "first line\n"; 30 print $tmp "second line\n"; 31 print $tmp "a line\n" x 1000; 32 close $tmp; 33 } 34 35 # Test eof followed by binmode for streams (fails under Windows) 36 { 37 my $fh = new FileHandle::Unget("$path_to_perl -e \"open F, '" . $tmp->filename . 38 "';binmode STDOUT;print <F>\" |"); 39 40 print '' if eof($fh); 41 binmode $fh; 42 43 # 1 44 is(scalar <$fh>,"first line\n"); 45 46 # 2 47 is(scalar <$fh>,"second line\n"); 48 49 $fh->close; 50 } 51} 52