/[webpac2]/trunk/lib/WebPAC/Normalize/Set.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/lib/WebPAC/Normalize/Set.pm

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

revision 500 by dpavlin, Sun May 14 12:35:20 2006 UTC revision 501 by dpavlin, Sun May 14 22:08:51 2006 UTC
# Line 5  use Exporter 'import'; Line 5  use Exporter 'import';
5          get_ds clean_ds          get_ds clean_ds
6          tag search display          tag search display
7          rec1 rec2 rec          rec1 rec2 rec
8          regex prefix          regex prefix suffix surround
9          first lookup join_with          first lookup join_with
10  /;  /;
11    
# Line 246  sub regex { Line 246  sub regex {
246          my @out;          my @out;
247          #warn "r: $r\n",Dumper(\@_);          #warn "r: $r\n",Dumper(\@_);
248          foreach my $t (@_) {          foreach my $t (@_) {
249                    next unless ($t);
250                  eval "\$t =~ $r";                  eval "\$t =~ $r";
251                  push @out, $t;                  push @out, $t if ($t && $t ne '');
252          }          }
253          return @out;          return @out;
254  }  }
# Line 265  sub prefix { Line 266  sub prefix {
266          return map { $p . $_ } grep { defined($_) } @_;          return map { $p . $_ } grep { defined($_) } @_;
267  }  }
268    
269    =head2 suffix
270    
271    suffix all values with a string
272    
273      @v = suffix( '_my', @v );
274    
275    =cut
276    
277    sub suffix {
278            my $s = shift or die "suffix needs string as first argument";
279            return map { $_ . $s } grep { defined($_) } @_;
280    }
281    
282    =head2 surround
283    
284    surround all values with a two strings
285    
286      @v = surround( 'prefix_', '_suffix', @v );
287    
288    =cut
289    
290    sub surround {
291            my $p = shift or die "surround need prefix as first argument";
292            my $s = shift or die "surround needs suffix as second argument";
293            return map { $p . $_ . $s } grep { defined($_) } @_;
294    }
295    
296  =head2 first  =head2 first
297    
298  Return first element  Return first element

Legend:
Removed from v.500  
changed lines
  Added in v.501

  ViewVC Help
Powered by ViewVC 1.1.26