in reply to Parse text file data to send a mail.
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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parse text file data to send a mail.
by rahu_6697 (Novice) on Feb 04, 2019 at 10:50 UTC | |
by hippo (Archbishop) on Feb 04, 2019 at 11:09 UTC | |
by poj (Abbot) on Feb 04, 2019 at 11:21 UTC |