If you need to save all the seperated data, here's a technique using an 'array of arrays'
If you're OK with case-sensitive data, then you could use the index method as shown in TedPride's post
use strict;
my @mail_item = ();
my $i = -1;
## open FIL ......
## while <FIL> {....
while (<DATA>) {
chomp $_;
if (/^from/i) { $i++; }
push @{ $mail_item[$i] }, $_;
}
## close FIL;
use Data::Dumper;
print Dumper(\@mail_item);
__DATA__
From: name1@domain.com time_sent1
From: name1@domain.com
some content1
From: name2@domain.com time_sent2
From: name2@domain.com
some content2
From: name3@domain.com time_sent3
From: name3@domain.com
some content3
From: name4@domain.com time_sent4
From: name4@domain.com
some content4
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.