Re: Tie::File surprise (to me)



In article <x7r6rao1yf.fsf@xxxxxxxxxxxxxxxx>,
Uri Guttman <uri@xxxxxxxxxxxxxxx> wrote:

"b" == boyd <tbmoore9@xxxxxxxxxxx> writes:

b> I probably should have known this, but didn't. In Tie::File, where you
b> tie an array to a long file, and you want to read backwards from the end
b> of it ( to look for the most recent lines, for example, in a log file),
b> it is much faster to address the lines with $index as a negative number,
b> meaning to search from the end of the array. It takes a while for the
b> module to find the index = -1, but the subsequent searches on -2, -3,
b> etc. are much faster than using @#array-1, @#array-2, etc.

you should use File::ReadBackwards for that. much faster than tying a
log file.

uri

Thanks, uri. I didn't know about File::ReadBackwards.

Boyd
.



Relevant Pages

  • Re: random array elements and speed
    ... I suppose the fact that both you and Uri gave rather similar ... JJ> incredibly sensitive to the size of the desired array. ... JJ> then yeah the splice method might well be two or three or four times as ... But the random selection method could be a ...
    (comp.lang.perl.misc)
  • Re: initialize a hash
    ... Paul Lalli schreef: ... keys coming from an array, and all values set to a constant like 1. ... Uri and Anno too of ...
    (comp.lang.perl.misc)
  • J# 2005 (Express Edition) Frage
    ... Hier kommt mir aber die Doku etwas komisch vor: System.Net.WebClient.DownloadDatasoll ein ubyte Array zurückgeben, steht in der Definition, aber im Object Browser steht unter Returns: ... A System.Byte array containing the downloaded resource. ... Downloads the resource with the specified URI as a System.Byte array. ...
    (microsoft.public.de.vc)
  • Re: short form for (defined $x and defined $y and ... )?
    ... AS> Unlike Uri, occasionally I do want to verify that all members of a ... AS> list (or an array) are defined. ... You insinuate a higher intelligence design while using code other folks program... ...
    (comp.lang.perl.misc)
  • Re: Tie::File surprise (to me)
    ... b> tie an array to a long file, and you want to read backwards from the end ... b> of it (to look for the most recent lines, for example, in a log file), ... b> meaning to search from the end of the array. ...
    (comp.lang.perl.modules)