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);