1#!/usr/bin/perl 2# 3# Make sure we can fetch a record in the middle of the file 4# before we've ever looked at any records before it 5# 6# (tests _fill_offsets_to() ) 7# 8 9use strict; 10use warnings; 11 12my $file = "tf12-$$.txt"; 13my $data = "rec0blahrec1blahrec2blah"; 14 15print "1..5\n"; 16 17my $N = 1; 18use Tie::File; 19print "ok $N\n"; $N++; 20 21open F, '>', $file or die $!; 22binmode F; 23print F $data; 24close F; 25 26my @a; 27my $o = tie @a, 'Tie::File', $file, autochomp => 0, recsep => 'blah'; 28print $o ? "ok $N\n" : "not ok $N\n"; 29$N++; 30 31my $n; 32 33# 3-5 34for (2, 1, 0) { 35 print $a[$_] eq "rec${_}blah" ? "ok $N\n" : "not ok $N # rec=$a[$_] ?\n"; 36 $N++; 37} 38 39END { 40 undef $o; 41 untie @a; 42 1 while unlink $file; 43} 44 45