Once I encountered a problem concerning an exported peagasus mailfile. It was several hundreds of megabytes big. My oportunity was to split it into parts, each containing exactly one mail. As the file had a nice seperator, it seemed quite easy to me - but the first attempt blew up my memory. This was the first time I came to use the $_ variable instead of an own:
open(FH,"<$source") || die "cant open $source: $!\n";
while (<FH>){
push @file, $_;
if ($_ =~ /^-- End --/) {
$zaehler++;
open(GUN,">$destiny") || die "can write to $destinyfile$zaehle
+r:$!";
foreach $zeile (@file) {
print GUN $zeile;
}#endforeach
undef @file;
close(GUN);
print "$zaehler:\n";
}#endif
}#endwhile
close(FH);
easy code, sent in the hope it helps you
there are no silly questions
killerhippy
Edit ar0n -- 2001-07-24 fixed excessive whitespace
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.