/[Search-Estraier]/trunk/Estraier.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/Estraier.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3 by dpavlin, Wed Jan 4 13:11:43 2006 UTC revision 4 by dpavlin, Wed Jan 4 13:33:07 2006 UTC
# Line 61  sub new { Line 61  sub new {
61          $self ? return $self : return undef;          $self ? return $self : return undef;
62  }  }
63    
64    
65  =head2 add_attr  =head2 add_attr
66    
67    $doc->add_attr( name => 'value' );    $doc->add_attr( name => 'value' );
# Line 72  sub add_attr { Line 73  sub add_attr {
73          my $attrs = {@_};          my $attrs = {@_};
74    
75          while (my ($name, $value) = each %{ $attrs }) {          while (my ($name, $value) = each %{ $attrs }) {
76                  $name =~ s/\s\s+/ /gs;                  push @{$self->{attrs}->{_s($name)}}, _s($value);
                 $value =~ s/\s\s+/ /gs;  
                 push @{$self->{$name}}, $value;  
77          }          }
78  }  }
79    
80    =head2 delete
81    
82    Empty document object
83    
84      $doc->delete;
85    
86    =cut
87    
88    sub delete {
89            my $self = shift;
90    
91            delete($self->{attrs});
92    
93            return 1;
94    }
95    
96    
97    =head2 _s
98    
99    Remove multiple whitespaces from string, as well as whitespaces at beginning or end
100    
101     my $text = _s(" this  is a text  ");
102     $text = 'this is a text';
103    
104    =cut
105    
106    sub _s {
107            my $text = shift || return;
108            $text =~ s/\s\s+/ /gs;
109            $text =~ s/^\s+//;
110            $text =~ s/\s+$//;
111            return $text;
112    }
113    
114    
115    
116  package Search::Estraier::Master;  package Search::Estraier::Master;

Legend:
Removed from v.3  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.26