in reply to Mailbox spliting and storing each message!

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