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

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

revision 13 by dpavlin, Sat Jul 16 23:56:14 2005 UTC revision 542 by dpavlin, Thu Jun 29 21:18:59 2006 UTC
# Line 1  Line 1 
1  package WebPAC::Normalize;  package WebPAC::Normalize;
2    use Exporter 'import';
3    @EXPORT = qw/
4            _set_rec _set_lookup
5            _get_ds _clean_ds
6    
7            tag search display
8            marc21
9    
10            rec1 rec2 rec
11            regex prefix suffix surround
12            first lookup join_with
13    /;
14    
15  use warnings;  use warnings;
16  use strict;  use strict;
17    
18    #use base qw/WebPAC::Common/;
19  use Data::Dumper;  use Data::Dumper;
20    use Encode qw/from_to/;
21    
22  =head1 NAME  =head1 NAME
23    
24  WebPAC::Normalize - normalisation of source file  WebPAC::Normalize - describe normalisaton rules using sets
25    
26  =head1 VERSION  =head1 VERSION
27    
28  Version 0.01  Version 0.06
29    
30  =cut  =cut
31    
32  our $VERSION = '0.01';  our $VERSION = '0.06';
33    
34  =head1 SYNOPSIS  =head1 SYNOPSIS
35    
36  This package contains code that could be helpful in implementing different  This module uses C<conf/normalize/*.pl> files to perform normalisation
37  normalisation front-ends.  from input records using perl functions which are specialized for set
38    processing.
39    
40    Sets are implemented as arrays, and normalisation file is valid perl, which
41    means that you check it's validity before running WebPAC using
42    C<perl -c normalize.pl>.
43    
44    Normalisation can generate multiple output normalized data. For now, supported output
45    types (on the left side of definition) are: C<tag>, C<display>, C<search> and
46    C<marc21>.
47    
48  =head1 FUNCTIONS  =head1 FUNCTIONS
49    
50  =head2 new  Functions which start with C<_> are private and used by WebPAC internally.
51    All other functions are available for use within normalisation rules.
 Create new normalisation object  
   
   my $n = new WebPAC::Normalize::Something(  
         cache_data_structure => './cache/ds/',  
         lookup_regex => $lookup->regex,  
   );  
52    
53  Optional parameter C<cache_data_structure> defines path to directory  =head2 data_structure
 in which cache file for C<data_structure> call will be created.  
   
 Recommended parametar C<lookup_regex> is used to enable parsing of lookups  
 in structures.  
   
 =cut  
   
 sub new {  
         my $class = shift;  
         my $self = {@_};  
         bless($self, $class);  
   
         $self->setup_cache_dir( $self->{'cache_data_structure'} );  
54    
55          $self ? return $self : return undef;  Return data structure
 }  
56    
57  =head2 setup_cache_dir    my $ds = WebPAC::Normalize::data_structure(
58            lookup => $lookup->lookup_hash,
59            row => $row,
60            rules => $normalize_pl_config,
61            marc_encoding => 'utf-8',
62      );
63    
64  Check if specified cache directory exist, and if not, disable caching.  Options C<lookup>, C<row>, C<rules> and C<log> are mandatory while all
65    other are optional.
66    
67   $setup_cache_dir('./cache/ds/');  This function will B<die> if normalizastion can't be evaled.
68    
69  If you pass false or zero value to this function, it will disable  Since this function isn't exported you have to call it with
70  cacheing.  C<WebPAC::Normalize::data_structure>.
71    
72  =cut  =cut
73    
74  sub setup_cache_dir {  sub data_structure {
75          my $self = shift;          my $arg = {@_};
   
         my $dir = shift;  
76    
77          my $log = $self->_get_logger();          die "need row argument" unless ($arg->{row});
78            die "need normalisation argument" unless ($arg->{rules});
79    
80          if ($dir) {          no strict 'subs';
81                  my $msg;          _set_lookup( $arg->{lookup} );
82                  if (! -e $dir) {          _set_rec( $arg->{row} );
83                          $msg = "doesn't exist";          _clean_ds( %{ $arg } );
84                  } elsif (! -d $dir) {          eval "$arg->{rules}";
85                          $msg = "is not directory";          die "error evaling $arg->{rules}: $@\n" if ($@);
                 } elsif (! -w $dir) {  
                         $msg = "not writable";  
                 }  
86    
87                  if ($msg) {          return _get_ds();
                         undef $self->{'cache_data_structure'};  
                         $log->warn("cache_data_structure $dir $msg, disabling...");  
                 } else {  
                         $log->debug("using cache dir $dir");  
                 }  
         } else {  
                 $log->debug("disabling cache");  
                 undef $self->{'cache_data_structure'};  
         }  
88  }  }
89    
90    =head2 _set_rec
91    
92  =head2 data_structure  Set current record hash
   
 Create in-memory data structure which represents normalized layout from  
 C<conf/normalize/*.xml>.  
93    
94  This structures are used to produce output.    _set_rec( $rec );
   
  my @ds = $webpac->data_structure($rec);  
   
 B<Note: historical oddity follows>  
   
 This method will also set C<< $webpac->{'currnet_filename'} >> if there is  
 C<< <filename> >> tag and C<< $webpac->{'headline'} >> if there is  
 C<< <headline> >> tag.  
95    
96  =cut  =cut
97    
98  sub data_structure {  my $rec;
         my $self = shift;  
99    
100          my $log = $self->_get_logger();  sub _set_rec {
101            $rec = shift or die "no record hash";
102    }
103    
104          my $rec = shift;  =head2 _get_ds
         $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);  
105    
106          my $cache_file;  Return hash formatted as data structure
107    
108          if (my $cache_path = $self->{'cache_data_structure'}) {    my $ds = _get_ds();
                 my $id = $rec->{'000'};  
                 $id = $rec->{'000'}->[0] if ($id =~ m/^ARRAY/o);  
                 unless (defined($id)) {  
                         $log->warn("Can't use cache_data_structure on records without unique identifier in field 000");  
                         undef $self->{'cache_data_structure'};  
                 } else {  
                         $cache_file = "$cache_path/$id";  
                         if (-r $cache_file) {  
                                 my $ds_ref = retrieve($cache_file);  
                                 if ($ds_ref) {  
                                         $log->debug("cache hit: $cache_file");  
                                         my $ok = 1;  
                                         foreach my $f (qw(current_filename headline)) {  
                                                 if ($ds_ref->{$f}) {  
                                                         $self->{$f} = $ds_ref->{$f};  
                                                 } else {  
                                                         $ok = 0;  
                                                 }  
                                         };  
                                         if ($ok && $ds_ref->{'ds'}) {  
                                                 return @{ $ds_ref->{'ds'} };  
                                         } else {  
                                                 $log->warn("cache_data_structure $cache_path corrupt. Use rm $cache_path/* to re-create it on next run!");  
                                                 undef $self->{'cache_data_structure'};  
                                         }  
                                 }  
                         }  
                 }  
         }  
109    
110          undef $self->{'currnet_filename'};  =cut
         undef $self->{'headline'};  
111    
112          my @sorted_tags;  my $out;
113          if ($self->{tags_by_order}) {  my $marc21;
114                  @sorted_tags = @{$self->{tags_by_order}};  my $marc_encoding;
         } else {  
                 @sorted_tags = sort { $self->_sort_by_order } keys %{$self->{'import_xml'}->{'indexer'}};  
                 $self->{tags_by_order} = \@sorted_tags;  
         }  
115    
116          my @ds;  sub _get_ds {
117            return $out;
118    }
119    
120          $log->debug("tags: ",sub { join(", ",@sorted_tags) });  =head2 _clean_ds
121    
122          foreach my $field (@sorted_tags) {  Clean data structure hash for next record
123    
124                  my $row;    _clean_ds();
125    
126  #print "field $field [",$self->{'tag'},"] = ",Dumper($self->{'import_xml'}->{'indexer'}->{$field}->{$self->{'tag'}});  =cut
127    
128                  foreach my $tag (@{$self->{'import_xml'}->{'indexer'}->{$field}->{$self->{'tag'}}}) {  sub _clean_ds {
129                          my $format = $tag->{'value'} || $tag->{'content'};          my $a = {@_};
130            $out = undef;
131            $marc21 = undef;
132            $marc_encoding = $a->{marc_encoding};
133    }
134    
135                          $log->debug("format: $format");  =head2 _set_lookup
136    
137                          my @v;  Set current lookup hash
                         if ($self->{'lookup_regex'} && $format =~ $self->{'lookup_regex'}) {  
                                 @v = $self->fill_in_to_arr($rec,$format);  
                         } else {  
                                 @v = $self->parse_to_arr($rec,$format);  
                         }  
                         next if (! @v);  
138    
139                          if ($tag->{'sort'}) {    _set_lookup( $lookup );
                                 @v = $self->sort_arr(@v);  
                         }  
140    
141                          # use format?  =cut
                         if ($tag->{'format_name'}) {  
                                 @v = map { $self->apply_format($tag->{'format_name'},$tag->{'format_delimiter'},$_) } @v;  
                         }  
   
                         if ($field eq 'filename') {  
                                 $self->{'current_filename'} = join('',@v);  
                                 $log->debug("filename: ",$self->{'current_filename'});  
                         } elsif ($field eq 'headline') {  
                                 $self->{'headline'} .= join('',@v);  
                                 $log->debug("headline: ",$self->{'headline'});  
                                 next; # don't return headline in data_structure!  
                         }  
142    
143                          # delimiter will join repeatable fields  my $lookup;
                         if ($tag->{'delimiter'}) {  
                                 @v = ( join($tag->{'delimiter'}, @v) );  
                         }  
144    
145                          # default types  sub _set_lookup {
146                          my @types = qw(display swish);          $lookup = shift;
147                          # override by type attribute  }
                         @types = ( $tag->{'type'} ) if ($tag->{'type'});  
   
                         foreach my $type (@types) {  
                                 # append to previous line?  
                                 $log->debug("type: $type ",sub { join(" ",@v) }, $row->{'append'} || 'no append');  
                                 if ($tag->{'append'}) {  
   
                                         # I will delimit appended part with  
                                         # delimiter (or ,)  
                                         my $d = $tag->{'delimiter'};  
                                         # default delimiter  
                                         $d ||= " ";  
   
                                         my $last = pop @{$row->{$type}};  
                                         $d = "" if (! $last);  
                                         $last .= $d . join($d, @v);  
                                         push @{$row->{$type}}, $last;  
   
                                 } else {  
                                         push @{$row->{$type}}, @v;  
                                 }  
                         }  
148    
149    =head2 _get_marc21_fields
150    
151                  }  Get all fields defined by calls to C<marc21>
152    
153                  if ($row) {          $marc->add_fields( WebPAC::Normalize:_get_marc21_fields() );
                         $row->{'tag'} = $field;  
154    
155                          # TODO: name_sigular, name_plural  B<TODO>: implement exceptions to magic which unrolls repeated subfields
156                          my $name = $self->{'import_xml'}->{'indexer'}->{$field}->{'name'};  as new field with that subfield.
                         $row->{'name'} = $name ? $self->_x($name) : $field;  
   
                         # post-sort all values in field  
                         if ($self->{'import_xml'}->{'indexer'}->{$field}->{'sort'}) {  
                                 $log->warn("sort at field tag not implemented");  
                         }  
157    
158                          push @ds, $row;  =cut
159    
160                          $log->debug("row $field: ",sub { Dumper($row) });  sub _get_marc21_fields {
161            my @m;
162            my $last;
163            foreach my $row (@{ $marc21 }) {
164                    if ($last && (
165                            $last->[0] eq $row->[0] ||              # check if field is same
166                            $last->[1] eq $row->[1] ||              # check for i1
167                            $last->[2] eq $row->[2]                 # and for i2
168                    ) ) {
169                            $last->[3]->{ $row->[3] } = $row->[4];
170                            warn "## ++ added $row->[0] ^$row->[3]\n";
171                            next;
172                    } elsif ($last) {
173                            push @m, $last;
174                  }                  }
175    
176                    push @m, $row;
177          }          }
178    
179          if ($cache_file) {          push @m, $last if ($last);
                 store {  
                         ds => \@ds,  
                         current_filename => $self->{'current_filename'},  
                         headline => $self->{'headline'},  
                 }, $cache_file;  
                 $log->debug("created storable cache file $cache_file");  
         }  
   
         return @ds;  
180    
181            return @m;
182  }  }
183    
184  =head2 apply_format  =head1 Functions to create C<data_structure>
   
 Apply format specified in tag with C<format_name="name"> and  
 C<format_delimiter=";;">.  
185    
186   my $text = $webpac->apply_format($format_name,$format_delimiter,$data);  Those functions generally have to first in your normalization file.
187    
188  Formats can contain C<lookup{...}> if you need them.  =head2 tag
189    
190  =cut  Define new tag for I<search> and I<display>.
   
 sub apply_format {  
         my $self = shift;  
191    
192          my ($name,$delimiter,$data) = @_;    tag('Title', rec('200','a') );
193    
         my $log = $self->_get_logger();  
194    
195          if (! $self->{'import_xml'}->{'format'}->{$name}) {  =cut
                 $log->warn("<format name=\"$name\"> is not defined in ",$self->{'import_xml_file'});  
                 return $data;  
         }  
196    
197          $log->warn("no delimiter for format $name") if (! $delimiter);  sub tag {
198            my $name = shift or die "tag needs name as first argument";
199            my @o = grep { defined($_) && $_ ne '' } @_;
200            return unless (@o);
201            $out->{$name}->{tag} = $name;
202            $out->{$name}->{search} = \@o;
203            $out->{$name}->{display} = \@o;
204    }
205    
206          my $format = $self->_x($self->{'import_xml'}->{'format'}->{$name}->{'content'}) || $log->logdie("can't find format '$name'");  =head2 display
207    
208          my @data = split(/\Q$delimiter\E/, $data);  Define tag just for I<display>
209    
210          my $out = sprintf($format, @data);    @v = display('Title', rec('200','a') );
         $log->debug("using format $name [$format] on $data to produce: $out");  
211    
212          if ($self->{'lookup_regex'} && $out =~ $self->{'lookup_regex'}) {  =cut
                 return $self->lookup($out);  
         } else {  
                 return $out;  
         }  
213    
214    sub display {
215            my $name = shift or die "display needs name as first argument";
216            my @o = grep { defined($_) && $_ ne '' } @_;
217            return unless (@o);
218            $out->{$name}->{tag} = $name;
219            $out->{$name}->{display} = \@o;
220  }  }
221    
222  =head2 parse  =head2 search
223    
224  Perform smart parsing of string, skipping delimiters for fields which aren't  Prepare values just for I<search>
 defined. It can also eval code in format starting with C<eval{...}> and  
 return output or nothing depending on eval code.  
225    
226   my $text = $webpac->parse($rec,'eval{"v901^a" eq "Deskriptor"}descriptor: v250^a', $i);    @v = search('Title', rec('200','a') );
227    
228  =cut  =cut
229    
230  sub parse {  sub search {
231          my $self = shift;          my $name = shift or die "search needs name as first argument";
232            my @o = grep { defined($_) && $_ ne '' } @_;
233          my ($rec, $format_utf8, $i) = @_;          return unless (@o);
234            $out->{$name}->{tag} = $name;
235            $out->{$name}->{search} = \@o;
236    }
237    
238          return if (! $format_utf8);  =head2 marc21
239    
240          my $log = $self->_get_logger();  Save value for MARC field
241    
242          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);    marc21('900','a', rec('200','a') );
243    
244          $i = 0 if (! $i);  =cut
245    
246          my $format = $self->_x($format_utf8) || $log->logconfess("can't convert '$format_utf8' from UTF-8 to ",$self->{'code_page'});  sub marc21 {
247            my $f = shift or die "marc21 needs field";
248            die "marc21 field must be numer" unless ($f =~ /^\d+$/);
249    
250          my @out;          my $sf = shift or die "marc21 needs subfield";
251    
252          $log->debug("format: $format");          foreach (@_) {
253                    my $v = $_;             # make var read-write for Encode
254                    next unless (defined($v) && $v !~ /^\s+$/);
255                    from_to($v, 'iso-8859-2', $marc_encoding) if ($marc_encoding);
256                    push @{ $marc21 }, [ $f, ' ', ' ', $sf => $v ];
257            }
258    }
259    
260          my $eval_code;  =head1 Functions to extract data from input
         # remove eval{...} from beginning  
         $eval_code = $1 if ($format =~ s/^eval{([^}]+)}//s);  
261    
262          my $filter_name;  This function should be used inside functions to create C<data_structure> described
263          # remove filter{...} from beginning  above.
         $filter_name = $1 if ($format =~ s/^filter{([^}]+)}//s);  
264    
265          my $prefix;  =head2 rec1
         my $all_found=0;  
266    
267          while ($format =~ s/^(.*?)(v|s)(\d+)(?:\^(\w))?//s) {  Return all values in some field
268    
269                  my $del = $1 || '';    @v = rec1('200')
                 $prefix ||= $del if ($all_found == 0);  
270    
271                  # repeatable index  TODO: order of values is probably same as in source data, need to investigate that
                 my $r = $i;  
                 $r = 0 if (lc("$2") eq 's');  
272    
273                  my $found = 0;  =cut
                 my $tmp = $self->get_data(\$rec,$3,$4,$r,\$found);  
274    
275                  if ($found) {  sub rec1 {
276                          push @out, $del;          my $f = shift;
277                          push @out, $tmp;          return unless (defined($rec) && defined($rec->{$f}));
278                          $all_found += $found;          if (ref($rec->{$f}) eq 'ARRAY') {
279                  }                  return map {
280                            if (ref($_) eq 'HASH') {
281                                    values %{$_};
282                            } else {
283                                    $_;
284                            }
285                    } @{ $rec->{$f} };
286            } elsif( defined($rec->{$f}) ) {
287                    return $rec->{$f};
288          }          }
289    }
290    
291          return if (! $all_found);  =head2 rec2
   
         my $out = join('',@out);  
   
         if ($out) {  
                 # add rest of format (suffix)  
                 $out .= $format;  
292    
293                  # add prefix if not there  Return all values in specific field and subfield
                 $out = $prefix . $out if ($out !~ m/^\Q$prefix\E/);  
294    
295                  $log->debug("result: $out");    @v = rec2('200','a')
         }  
296    
297          if ($eval_code) {  =cut
                 my $eval = $self->fill_in($rec,$eval_code,$i) || return;  
                 $log->debug("about to eval{$eval} format: $out");  
                 return if (! $self->_eval($eval));  
         }  
           
         if ($filter_name && $self->{'filter'}->{$filter_name}) {  
                 $log->debug("about to filter{$filter_name} format: $out");  
                 $out = $self->{'filter'}->{$filter_name}->($out);  
                 return unless(defined($out));  
                 $log->debug("filter result: $out");  
         }  
298    
299          return $out;  sub rec2 {
300            my $f = shift;
301            return unless (defined($rec && $rec->{$f}));
302            my $sf = shift;
303            return map { $_->{$sf} } grep { ref($_) eq 'HASH' && $_->{$sf} } @{ $rec->{$f} };
304  }  }
305    
306  =head2 parse_to_arr  =head2 rec
307    
308  Similar to C<parse>, but returns array of all repeatable fields  syntaxtic sugar for
309    
310   my @arr = $webpac->parse_to_arr($rec,'v250^a');    @v = rec('200')
311      @v = rec('200','a')
312    
313  =cut  =cut
314    
315  sub parse_to_arr {  sub rec {
316          my $self = shift;          if ($#_ == 0) {
317                    return rec1(@_);
318            } elsif ($#_ == 1) {
319                    return rec2(@_);
320            }
321    }
322    
323          my ($rec, $format_utf8) = @_;  =head2 regex
324    
325          my $log = $self->_get_logger();  Apply regex to some or all values
326    
327          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);    @v = regex( 's/foo/bar/g', @v );
         return if (! $format_utf8);  
328    
329          my $i = 0;  =cut
         my @arr;  
330    
331          while (my $v = $self->parse($rec,$format_utf8,$i++)) {  sub regex {
332                  push @arr, $v;          my $r = shift;
333            my @out;
334            #warn "r: $r\n",Dumper(\@_);
335            foreach my $t (@_) {
336                    next unless ($t);
337                    eval "\$t =~ $r";
338                    push @out, $t if ($t && $t ne '');
339          }          }
340            return @out;
         $log->debug("format '$format_utf8' returned ",--$i," elements: ", sub { join(" | ",@arr) }) if (@arr);  
   
         return @arr;  
341  }  }
342    
343  =head2 fill_in_to_arr  =head2 prefix
344    
345  Similar to C<fill_in>, but returns array of all repeatable fields. Usable  Prefix all values with a string
 for fields which have lookups, so they shouldn't be parsed but rather  
 C<fill_id>ed.  
346    
347   my @arr = $webpac->fill_in_to_arr($rec,'[v900];;[v250^a]');    @v = prefix( 'my_', @v );
348    
349  =cut  =cut
350    
351  sub fill_in_to_arr {  sub prefix {
352          my $self = shift;          my $p = shift or die "prefix needs string as first argument";
353            return map { $p . $_ } grep { defined($_) } @_;
354          my ($rec, $format_utf8) = @_;  }
   
         my $log = $self->_get_logger();  
355    
356          $log->logconfess("need HASH as first argument!") if ($rec !~ /HASH/o);  =head2 suffix
         return if (! $format_utf8);  
357    
358          my $i = 0;  suffix all values with a string
         my @arr;  
359    
360          while (my @v = $self->fill_in($rec,$format_utf8,$i++)) {    @v = suffix( '_my', @v );
                 push @arr, @v;  
         }  
361    
362          $log->debug("format '$format_utf8' returned ",--$i," elements: ", sub { join(" | ",@arr) }) if (@arr);  =cut
363    
364          return @arr;  sub suffix {
365            my $s = shift or die "suffix needs string as first argument";
366            return map { $_ . $s } grep { defined($_) } @_;
367  }  }
368    
369  =head2 sort_arr  =head2 surround
370    
371  Sort array ignoring case and html in data  surround all values with a two strings
372    
373   my @sorted = $webpac->sort_arr(@unsorted);    @v = surround( 'prefix_', '_suffix', @v );
374    
375  =cut  =cut
376    
377  sub sort_arr {  sub surround {
378          my $self = shift;          my $p = shift or die "surround need prefix as first argument";
379            my $s = shift or die "surround needs suffix as second argument";
380          my $log = $self->_get_logger();          return map { $p . $_ . $s } grep { defined($_) } @_;
   
         # FIXME add Schwartzian Transformation?  
   
         my @sorted = sort {  
                 $a =~ s#<[^>]+/*>##;  
                 $b =~ s#<[^>]+/*>##;  
                 lc($b) cmp lc($a)  
         } @_;  
         $log->debug("sorted values: ",sub { join(", ",@sorted) });  
   
         return @sorted;  
381  }  }
382    
383    =head2 first
384    
385  =head2 _sort_by_order  Return first element
386    
387  Sort xml tags data structure accoding to C<order=""> attribute.    $v = first( @v );
388    
389  =cut  =cut
390    
391  sub _sort_by_order {  sub first {
392          my $self = shift;          my $r = shift;
393            return $r;
         my $va = $self->{'import_xml'}->{'indexer'}->{$a}->{'order'} ||  
                 $self->{'import_xml'}->{'indexer'}->{$a};  
         my $vb = $self->{'import_xml'}->{'indexer'}->{$b}->{'order'} ||  
                 $self->{'import_xml'}->{'indexer'}->{$b};  
   
         return $va <=> $vb;  
394  }  }
395    
396  =head2 _x  =head2 lookup
   
 Convert strings from C<conf/normalize> encoding into application specific  
 (optinally specified using C<code_page> to C<new> constructor.  
397    
398   my $text = $n->_x('normalize text string');  Consult lookup hashes for some value
399    
400  This is a stub so that other modules doesn't have to implement it.    @v = lookup( $v );
401      @v = lookup( @v );
402    
403  =cut  =cut
404    
405  sub _x {  sub lookup {
406          my $self = shift;          my $k = shift or return;
407          return shift;          return unless (defined($lookup->{$k}));
408            if (ref($lookup->{$k}) eq 'ARRAY') {
409                    return @{ $lookup->{$k} };
410            } else {
411                    return $lookup->{$k};
412            }
413  }  }
414    
415    =head2 join_with
416    
417  =head1 AUTHOR  Joins walues with some delimiter
   
 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>  
   
 =head1 COPYRIGHT & LICENSE  
418    
419  Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.    $v = join_with(", ", @v);
   
 This program is free software; you can redistribute it and/or modify it  
 under the same terms as Perl itself.  
420    
421  =cut  =cut
422    
423  1; # End of WebPAC::DB  sub join_with {
424            my $d = shift;
425            return join($d, grep { defined($_) && $_ ne '' } @_);
426    }
427    
428    # END
429    1;

Legend:
Removed from v.13  
changed lines
  Added in v.542

  ViewVC Help
Powered by ViewVC 1.1.26