Since you already have one method of sending the mail, that's not pertinent to changing the input so I'll omit it here. This is one example of how to parse the sort of input you have. It's a bit verbose and is far from the only way to do it.

#!/usr/bin/env perl use strict; use warnings; use Data::Dumper; my %parts; my $key; while (my $line = <DATA>) { if ($line =~ /^([A-Z]+)$/) { $key = $1; if ($key =~ /^END/) { undef $key; } next; } next unless defined $key; $parts{$key} //= ''; $parts{$key} .= $line; } print Dumper (\%parts); __DATA__ TO rahul@example.com,you@everyone.com ENDTO SUBJECT Weekly status snapshot for WW-5 ENDSUBJECT BODY Hi All, Weekly progress snapshot for this week will be taken on Thursday, 30 J +an at the end of the day. ( Please update your status before the snap +shot) Use work week number as 5 for this week's updates . Note : If you want any additional data to be picked up ( or dropped ) +from your sheets, do work with me so that status collation script can + be updated to do this . Thanks , -Ram ENDBODY

Data::Dumper is only used here as an easy way to display the hash once constructed. You won't need that in your final program.


In reply to Re: Parse text file data to send a mail. by hippo
in thread Parse text file data to send a mail. by rahu_6697

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.