Re: [PATCH v4 4/6] send-email: create email parser subroutine
- From
- Eric Wong <e@80x24.org>
- Date
- Jun 8, 2016, 20:38 UTC
- Message-ID
- <20160608203858.GA513@dcvr.yhbt.net>
- In-Reply-To
- <20160608130142.29879-5-samuel.groot@grenoble-inp.org>
Samuel GROOT <samuel.groot@grenoble-inp.org> wrote:
> +++ b/perl/Git.pm
Show 6 quoted lines
> +sub parse_email {
> + my %mail = ();
> + my $fh = shift;
> + my $last_header;
> +
> + # Unfold and parse multiline header fieldsWhen you libify, I suggest you localize $/ since $/ may be set to something other than "\n" by a caller and change the behavior of <$fh> and $fh->getline.
local $/ = "\n";
> + while (<$fh>) {
> + last if /^\s*$/;
> + s/\r\n|\n|\r//;And, as Eric Sunshine stated:
s/\r?\n$//;
Explicitly localizing $/ means you wouldn't have to worry about multiple \n showing up in the line, either. And chomp/chop wouldn't work, here.
Otherwise I like the move to Git.pm, thanks.