Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^3: Displaying/buffering huge text files

by Anonymous Monk
on Dec 23, 2011 at 01:03 UTC ( #944878=note: print w/replies, xml ) Need Help??

in reply to Re^2: Displaying/buffering huge text files
in thread Displaying/buffering huge text files

Us N instead of non-portable J.
my $index = pack 'N', 0; $index .= pack 'N', tell FILE while <FILE>; for( my $line_idx = $s; $line_idx < $fileLastLine; $line_idx++ ) { my $line = unpack( 'N', substr($index, $line_idx*4, 4)); seek FILE, $line, 0; chomp( $_ = <FILE> ); my $line_str = $_;

Replies are listed 'Best First'.
Re^4: Displaying/buffering huge text files
by BrowserUk (Pope) on Dec 23, 2011 at 03:55 UTC
    Us N instead of non-portable J.

    'J' may be non-portable, but why oh why would you build an index on one machine and the export it to another? (Hint:You wouldn't unless you are naive!)

    The reason for using 'J' in preference to 'N', is that it is 'native'. That is, whatever architecture of machine you use it on it uses the format that is natural, and therefore most efficient, for that machine.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    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.

    The start of some sanity?

Re^4: Displaying/buffering huge text files
by mjbiren (Initiate) on Dec 23, 2011 at 01:11 UTC
    In case it isn't clear, $s is for start, the line to start on. For $fileLastLine I used:
    my $fileLastLine = `wc -l ${filename}`; chomp $fileLastLine; $fileLastLine = int ($fileLastLine);

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://944878]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2020-09-26 04:14 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (141 votes). Check out past polls.