1#!./perl 2 3BEGIN: { 4 chdir 't'; 5 @INC = '../lib'; 6 require './test.pl'; 7} 8 9plan(tests => 6); 10 11open(TRY,'>Comp.try') || (die "Can't open temp file."); 12 13$x = 'now is the time 14for all good men 15to come to. 16 17 18! 19 20'; 21 22$y = 'now is the time' . "\n" . 23'for all good men' . "\n" . 24'to come to.' . "\n\n\n!\n\n"; 25 26is($x, $y, 'test data is sane'); 27 28print TRY $x; 29close TRY or die "Could not close: $!"; 30 31open(TRY,'Comp.try') || (die "Can't reopen temp file."); 32$count = 0; 33$z = ''; 34while (<TRY>) { 35 $z .= $_; 36 $count = $count + 1; 37} 38 39is($z, $y, 'basic multiline reading'); 40 41is($count, 7, ' line count'); 42is($., 7, ' $.' ); 43 44$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type Comp.try` 45 : ($^O eq 'MacOS') ? `catenate Comp.try` 46 : `cat Comp.try`; 47 48like($out, qr/.*\n.*\n.*\n$/); 49 50close(TRY) || (die "Can't close temp file."); 51unlink 'Comp.try' || `/bin/rm -f Comp.try`; 52 53is($out, $y); 54