Skip Menu |

This queue is for tickets about the Search-Dict CPAN distribution.

Report information
The Basics
Id: 88299
Status: new
Priority: 0/
Queue: Search-Dict

People
Owner: Nobody in particular
Requestors: user42 [...] zip.com.au
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: size by seek not back to start
Date: Sat, 31 Aug 2013 10:35:37 +1000
To: bug-Search-Dict [...] rt.cpan.org
From: Kevin Ryde <user42 [...] zip.com.au>
In Search::Dict 0.7 the file size is found by $size = do { seek($fh,0,2); my $s = tell($fh); seek($fh,0,0); $s } As a tiny optimization I think the second seek is unnecessary. No assumptions are made about the $fh position on entry so can freely muck about with it for the size. For tightness perhaps an error check at that point too. The subsequent error checks catch unseekable too but this would be the first place to notice. my($size, $blksize) = @stat[7,11]; unless (defined $size) { seek($fh,0,2) && ($size = tell($fh)) >= 0 or return -1; } Tested with Dict.t and an unseekable made by { package MyTieUnseekable; use vars '@ISA'; @ISA = ('Tie::StdHandle'); sub SEEK { # Test::More::diag "unseekable"; return 0; # fail } }