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