Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Large text files into arrays, accessing final elements

by Not_a_Number (Parson)
on Feb 07, 2010 at 19:09 UTC ( #821864=note: print w/replies, xml ) Need Help??


in reply to Large text files into arrays, accessing final elements

if @myfile is tied file array: (...) $size=@myfile; #this dies and gives "out of memory" error

This issue seems to be directly addressed in the docs to Tie::File (in the caveats):

Note that accessing the length of the array via $x = scalar @tied_file accesses all records and stores their offsets.

Did you try, for example:

print $myfile[-1];

Replies are listed 'Best First'.
Re^2: Large text files into arrays, accessing final elements
by BrowserUk (Pope) on Feb 07, 2010 at 19:55 UTC
    Did you try, for example: print $myfile[-1];

    That will suffer exactly the same problems. There is simply no way to know how many lines a file (with variable length lines) contains without reading the whole file.


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://821864]
help
Chatterbox?
[choroba]: BTW, both the bands I play in performed on Friday (at the same event). Quite an exhausting experience.
[Corion]: choroba: Ooof! I can imagine that ;)
[Corion]: I think at a Perl workshop some years ago I gave two talks on the same day and after that decided to only submit one talk per event ;)
[LanX]: you play the triangle, right?

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2017-03-27 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (319 votes). Check out past polls.