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
9my $file = "tf12-$$.txt";
10my $data = "rec0blahrec1blahrec2blah";
11
12print "1..5\n";
13
14my $N = 1;
15use Tie::File;
16print "ok $N\n"; $N++;
17
18open F, '>', $file or die $!;
19binmode F;
20print F $data;
21close F;
22
23
24my $o = tie @a, 'Tie::File', $file, autochomp => 0, recsep => 'blah';
25print $o ? "ok $N\n" : "not ok $N\n";
26$N++;
27
28my $n;
29
30# 3-5
31for (2, 1, 0) {
32  print $a[$_] eq "rec${_}blah" ? "ok $N\n" : "not ok $N # rec=$a[$_] ?\n";
33  $N++;
34}
35
36END {
37  undef $o;
38  untie @a;
39  1 while unlink $file;
40}
41
42