rs.t revision 7c478bd95313f5f23a4c958a745db2134aa03244
#!./perl
# Test $!
print "1..16\n";
$teststring = "1\n12\n123\n1234\n1234\n12345\n\n123456\n1234567\n";
# Create our test datafile
rmdir 'foo';
print TESTFILE $teststring;
# Check the default $/
# explicitly set to \n
$/ = "\n";
# Try a non line terminator
$/ = 3;
# Eat the line terminator
$/ = "\n";
# How about a larger terminator
$/ = "34";
# Eat the line terminator
$/ = "\n";
# Does paragraph mode work?
$/ = '';
# Try slurping the rest of the file
$/ = undef;
# try the record reading tests. New file so we don't have to worry about
# the size of \n.
unlink "./foo";
print TESTFILE "1234567890123456789012345678901234567890";
# Test straight number
$/ = \2;
# Test stringified number
$/ = \"2";
$bar = <TESTFILE>;
# Integer variable
$foo = 2;
$/ = \$foo;
$bar = <TESTFILE>;
# String variable
$/ = \$foo;
$bar = <TESTFILE>;
close TESTFILE;
# Now for the tricky bit--full record reading
if ($^O eq 'VMS') {
# Create a temp file. We jump through these hoops 'cause CREATE really
# doesn't like our methods for some reason.
close FDLFILE;
print CREATEFILE '$ CLOSE YOW', "\n";
close CREATEFILE;
print TEMPFILE "foo\nfoobar\nbaz\n";
$/ = \10;
# can we do a short read?
$/ = \2;
# do we get the rest of the record?
} else {
# Nobody else does this at the moment (well, maybe OS/390, but they can
# put their own tests in) so we just punt
}
$/ = "\n";
{
my $line = <$T>;
}
else {
print "not ";
}
print "ok 15\n";
}
{
my $line = <$T>;
}
else {
print "not ";
}
print "ok 16\n";
}
# Get rid of the temp file