diff -r 5f6309f60053 -r 6276861aa7d4 lib/Message/2822.pm --- a/lib/Message/2822.pm Thu Nov 10 13:54:01 2011 +0100 +++ b/lib/Message/2822.pm Thu Nov 10 16:02:15 2011 +0100 @@ -8,15 +8,14 @@ use if $ENV{DEBUG} => "Smart::Comments"; my %DATA = ( - fn => {}, - fh => {}, - header => {}, + fn => {}, + fh => {}, + header => {}, body_pos => {}, ); lock_keys %DATA; - sub new { my $class = ref $_[0] ? ref shift : shift; my $self = bless \(my $x) => $class; @@ -24,10 +23,10 @@ $DATA{fn}{$self} = $arg{file}; $DATA{fh}{$self} = my $fh = IO::File->new($DATA{fn}{$self}) - or die "Can't open $DATA{fn}{$self}: $!\n"; + or die "Can't open $DATA{fn}{$self}: $!\n"; local $/ = ""; - $DATA{header}{$self} = <$fh>; + $DATA{header}{$self} = <$fh>; $DATA{body_pos}{$self} = tell($fh); return $self; @@ -36,26 +35,24 @@ sub __header_fields { my $self = shift; my %h; - @h{$DATA{header}{$self} - =~ /^(\S+?[: ])/mg} = (); + @h{ $DATA{header}{$self} =~ /^(\S+?[: ])/mg } = (); return keys %h; } sub header_content { - my $self = shift; + my $self = shift; my $field = shift; ### assert: $field =~ /[: ]$/ # FIXME: not sure if the space following the header field name # is optional or required - return $DATA{header}{$self} - =~ /^$field\s+(.*?)(?=^\S)/imsg; + return $DATA{header}{$self} =~ /^$field\s+(.*?)(?=^\S)/imsg; } sub orig_header { my $self = shift; - my $fh = $DATA{fh}{$self}; + my $fh = $DATA{fh}{$self}; seek($fh, 0, 0); local $/ = ""; return <$fh>; @@ -63,7 +60,7 @@ sub orig_body { my $self = shift; - my $fh = $DATA{fh}{$self}; + my $fh = $DATA{fh}{$self}; seek($fh, $DATA{body_pos}{$self}, 0); local $/ = undef; return <$fh>; @@ -72,7 +69,7 @@ sub DESTROY { my $self = shift; foreach (keys %DATA) { - delete $DATA{$_}{$self} + delete $DATA{$_}{$self}; } }