I'm scratching my head wondering how you got 50+M of data into the text widget in the first place, which also leads me to wonder whether part of the problem might be how you are loading data into the widget, as well as how you are getting data out of it for storing to a file. (Any chance you might actually be putting
three copies of the data in memory at the same time?) In case that could be part of the problem, you might find some interesting stuff on this thread:
Displaying/buffering huge text files. (Updated link to point to top of thread, rather than my own reply to it.)
Short of that, there's no reason to create a duplicate of 50+M of data all at once. Treat it like a big input file and loop over the content as you move it to the output file:
open( OUT, ">some_file.txt" ) or die $!;
my $startline = 1;
my $linespan = 100;
while (1) {
my $startid = sprintf( "%.1f", $startline );
my $txt = $text_widget->get( $startid, "+ $linespan lines" );
last unless length( $txt );
print OUT $txt;
$startline += $linespan;
}
close OUT;
Just like in normal file i/o, Tk::Text->get will return an empty string when the requested range falls entirely beyond the end of the current text content.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.