--- trunk/lib/WebPAC/Normalize/Set.pm 2006/05/14 22:07:38 500 +++ trunk/lib/WebPAC/Normalize/Set.pm 2006/05/14 22:08:51 501 @@ -5,7 +5,7 @@ get_ds clean_ds tag search display rec1 rec2 rec - regex prefix + regex prefix suffix surround first lookup join_with /; @@ -246,8 +246,9 @@ my @out; #warn "r: $r\n",Dumper(\@_); foreach my $t (@_) { + next unless ($t); eval "\$t =~ $r"; - push @out, $t; + push @out, $t if ($t && $t ne ''); } return @out; } @@ -265,6 +266,33 @@ return map { $p . $_ } grep { defined($_) } @_; } +=head2 suffix + +suffix all values with a string + + @v = suffix( '_my', @v ); + +=cut + +sub suffix { + my $s = shift or die "suffix needs string as first argument"; + return map { $_ . $s } grep { defined($_) } @_; +} + +=head2 surround + +surround all values with a two strings + + @v = surround( 'prefix_', '_suffix', @v ); + +=cut + +sub surround { + my $p = shift or die "surround need prefix as first argument"; + my $s = shift or die "surround needs suffix as second argument"; + return map { $p . $_ . $s } grep { defined($_) } @_; +} + =head2 first Return first element