02_fetchsize.t

来自「source of perl for linux application,」· T 代码 · 共 54 行

T
54
字号
#!/usr/bin/perlmy $file = "tf$$.txt";$: = Tie::File::_default_recsep();my $data = "rec1$:rec2$:rec3$:";print "1..6\n";my $N = 1;use Tie::File;print "ok $N\n"; $N++;open F, "> $file" or die $!;binmode F;print F $data;close F;my $o = tie @a, 'Tie::File', $file, autochomp => 0;print $o ? "ok $N\n" : "not ok $N\n";$N++;$: = $o->{recsep};my $n;# 3  test array element count$n = @a;print $n == 3 ? "ok $N\n" : "not ok $N # n=$n\n";$N++;# 4 same thing again   $n = @a;print $n == 3 ? "ok $N\n" : "not ok $N # n=$n\n";$N++;# 5  test $#a notation$n = $#a;print $n == 2 ? "ok $N\n" : "not ok $N # n=$n\n";$N++;# 6  test looping over array elementsmy $q;for (@a) { $q .= $_ }print $q eq $data ? "ok $N\n" : "not ok $N # n=$n\n";$N++;END {  undef $o;  untie @a;  1 while unlink $file;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?