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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |