X-Git-Url: http://git.jankratochvil.net/?p=PerlMail.git;a=blobdiff_plain;f=PerlMail%2FContacts.pm;h=0767261bcf87d5abf620fd338b3bc1e553ff018d;hp=4f04ccae65bec104c55320d4c95ae81b1da1a47a;hb=77c63c5ed9fa4b3c5d2110e70c3d66701dec763c;hpb=2a51f3d04a7e9ddd4268ef31e425073cbdad167a diff --git a/PerlMail/Contacts.pm b/PerlMail/Contacts.pm index 4f04cca..0767261 100644 --- a/PerlMail/Contacts.pm +++ b/PerlMail/Contacts.pm @@ -1,7 +1,7 @@ #! /usr/bin/perl # # $Id$ -# Copyright (C) 2002-2003 Jan Kratochvil +# Copyright (C) 2002-2004 Jan Kratochvil # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,54 +35,10 @@ my $self=bless { return $self; } -sub _parse -{ -my($self,$data,@headers)=@_; - - my $re=join("(.*?)(\r\n)?",map("\Q[$_]\E\r\n",@headers)); - $re=qr/^$re/s; - my @r=(); - while (my @items=($data=~/$re/s)) { - my %h=(); - for my $i (0..$#headers) { - $h{$headers[$i]}=(!$items[2*$i+1] ? undef : $items[2*$i+0]) - } - push @r,\%h; - $data=substr($data,length $&); - } - die "Unrecognized data (parsing ".join("/",@headers)."): $data" if $data; - return @r; -} - -sub in -{ -my($self,$data)=@_; - - $self=$self->new() if !ref $self; - push @{$self->{"data"}},map({ - [ $self->_parse($_->{"RECORD"}."\r\n","FIELD","FIELD-NAME","FIELD-DATA","FIELD-END") ]; - } $self->_parse($data,"RECORD","RECORD-END")); - return (wantarray() ? @{$self->{"data"}} : $self->{"data"}); -} +# sub in +# my($self,$data)=@_; -sub _join -{ -my($self,$href,@headers)=@_; - - my $trailer=pop @headers; - return join("",map(("[$_]\r\n".(!defined $href->{$_} ? "" : $href->{$_}."\r\n")),@headers))."[$trailer]\r\n"; -} - -sub out -{ -my($self,$data)=@_; - - $data=$self->{"data"} if !$data; - return join("",map({ - "[RECORD]\r\n".join("",map({ - $self->_join($_,"FIELD","FIELD-NAME","FIELD-DATA","FIELD-END"); - } @$_))."[RECORD-END]\r\n"; - } @$data)); -} +# sub out +# my($self,$data)=@_; 1;