#! /usr/bin/perl
#
# $Id$
-# Copyright (C) 2002-2003 Jan Kratochvil <project-PerlMail@jankratochvil.net>
+# Copyright (C) 2002-2004 Jan Kratochvil <project-PerlMail@jankratochvil.net>
#
# 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
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 import
-{
-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 export
-{
-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;