debug_print('Parsing Email');
$input_email = Email::MIME->new($mail_text);
- my %fields;
+ my %fields = %{ $switch{'default'} || {} };
my $summary = $input_email->header('Subject');
if ($summary =~ /\[\S+ (\d+)\](.*)/i) {
}
$fields{'comment'} = $comment;
+ my %override = %{ $switch{'override'} || {} };
+ foreach my $key (keys %override) {
+ $fields{$key} = $override{$key};
+ }
+
debug_print("Parsed Fields:\n" . Dumper(\%fields), 2);
return \%fields;
$SIG{__DIE__} = \&die_handler;
-GetOptions(\%switch, 'help|h', 'verbose|v+');
+GetOptions(\%switch, 'help|h', 'verbose|v+', 'default=s%', 'override=s%');
$switch{'verbose'} ||= 0;
# Print the help message if that switch was selected.
=head1 SYNOPSIS
- ./email_in.pl [-vvv] < email.txt
+./email_in.pl [-vvv] [--default name=value] [--override name=value] < email.txt
+
+Reads an email on STDIN (the standard input).
+
+Options:
+
+ --verbose (-v) - Make the script print more to STDERR.
+ Specify multiple times to print even more.
- Reads an email on STDIN (the standard input).
+ --default name=value - Specify defaults for field values, like
+ product=TestProduct. Can be specified multiple
+ times to specify defaults for multiple fields.
- Options:
- --verbose (-v) - Make the script print more to STDERR.
- Specify multiple times to print even more.
+ --override name=value - Override field values specified in the email,
+ like product=TestProduct. Can be specified
+ multiple times to override multiple fields.
=head1 DESCRIPTION