source: trunk/gsdl/perllib/plugins/RecPlug.pm@ 10156

Last change on this file since 10156 was 10156, checked in by davidb, 19 years ago

Extra functionality introduced to support incremental building.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.6 KB
Line 
1###########################################################################
2#
3# RecPlug.pm --
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26# RecPlug is a plugin which recurses through directories processing
27# each file it finds.
28
29# RecPlug has one option: use_metadata_files. When this is set, it will
30# check each directory for an XML file called "metadata.xml" that specifies
31# metadata for the files (and subdirectories) in the directory.
32#
33# Here's an example of a metadata file that uses three FileSet structures
34# (ignore the # characters):
35
36#<?xml version="1.0" encoding="UTF-8" standalone="no"?>
37#<!DOCTYPE DirectoryMetadata SYSTEM "http://greenstone.org/dtd/DirectoryMetadata/1.0/DirectoryMetadata.dtd">
38#<DirectoryMetadata>
39# <FileSet>
40# <FileName>nugget.*</FileName>
41# <Description>
42# <Metadata name="Title">Nugget Point, The Catlins</Metadata>
43# <Metadata name="Place" mode="accumulate">Nugget Point</Metadata>
44# </Description>
45# </FileSet>
46# <FileSet>
47# <FileName>nugget-point-1.jpg</FileName>
48# <Description>
49# <Metadata name="Title">Nugget Point Lighthouse, The Catlins</Metadata>
50# <Metadata name="Subject">Lighthouse</Metadata>
51# </Description>
52# </FileSet>
53# <FileSet>
54# <FileName>kaka-point-dir</FileName>
55# <Description>
56# <Metadata name="Title">Kaka Point, The Catlins</Metadata>
57# </Description>
58# </FileSet>
59#</DirectoryMetadata>
60
61# Metadata elements are read and applied to files in the order they appear
62# in the file.
63#
64# The FileName element describes the subfiles in the directory that the
65# metadata applies to as a perl regular expression (a FileSet group may
66# contain multiple FileName elements). So, <FileName>nugget.*</FileName>
67# indicates that the metadata records in the following Description block
68# apply to every subfile that starts with "nugget". For these files, a
69# Title metadata element is set, overriding any old value that the Title
70# might have had.
71#
72# Occasionally, we want to have multiple metadata values applied to a
73# document; in this case we use the "mode=accumulate" attribute of the
74# particular Metadata element. In the second metadata element of the first
75# FileSet above, the "Place" metadata is accumulating, and may therefore be
76# given several values. If we wanted to override these values and use a
77# single metadata element again, we could set the mode attribute to
78# "override" instead. Remember: every element is assumed to be in override
79# mode unless you specify otherwise, so if you want to accumulate metadata
80# for some field, every occurance must have "mode=accumulate" specified.
81#
82# The second FileSet element above applies to a specific file, called
83# nugget-point-1.jpg. This element overrides the Title metadata set in the
84# first FileSet, and adds a "Subject" metadata field.
85#
86# The third and final FileSet sets metadata for a subdirectory rather than
87# a file. The metadata specified (a Title) will be passed into the
88# subdirectory and applied to every file that occurs in the subdirectory
89# (and to every subsubdirectory and its contents, and so on) unless the
90# metadata is explictly overridden later in the import.
91
92
93
94package RecPlug;
95
96use BasPlug;
97use plugin;
98use util;
99
100use File::Basename;
101
102
103BEGIN {
104 @RecPlug::ISA = ('BasPlug');
105 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
106}
107
108use XMLParser;
109
110my $arguments =
111 [ { 'name' => "block_exp",
112 'desc' => "{BasPlug.block_exp}",
113 'type' => "regexp",
114 'deft' => &get_default_block_exp(),
115 'reqd' => "no" },
116 { 'name' => "use_metadata_files",
117 'desc' => "{RecPlug.use_metadata_files}",
118 'type' => "flag",
119 'reqd' => "no" },
120 { 'name' => "recheck_directories",
121 'desc' => "{RecPlug.recheck_directories}",
122 'type' => "flag",
123 'reqd' => "no" } ];
124
125my $options = { 'name' => "RecPlug",
126 'desc' => "{RecPlug.desc}",
127 'abstract' => "no",
128 'inherits' => "yes",
129 'args' => $arguments };
130
131
132my ($self);
133sub new {
134 my $class = shift (@_);
135
136 # $self is global for use within subroutines called by XML::Parser
137 $self = new BasPlug ($class, @_);
138
139 # 14-05-02 To allow for proper inheritance of arguments - John Thompson
140 my $option_list = $self->{'option_list'};
141 push( @{$option_list}, $options );
142
143 if (!parsargv::parse(\@_,
144 q^use_metadata_files^, \$self->{'use_metadata_files'},
145 q^recheck_directories^, \$self->{'recheck_directories'},
146 "allow_extra_options")) {
147 print STDERR "\nRecPlug uses an incorrect option.\n";
148 print STDERR "Check your collect.cfg configuration file.\n\n";
149 $self->print_txt_usage(""); # Use default resource bundle
150 die "\n";
151 }
152
153 if ($self->{'use_metadata_files'}) {
154 # create XML::Parser object for parsing metadata.xml files
155 my $parser = new XML::Parser('Style' => 'Stream',
156 'Handlers' => {'Char' => \&Char,
157 'Doctype' => \&Doctype
158 });
159 $self->{'parser'} = $parser;
160 $self->{'in_filename'} = 0;
161 }
162
163 $self->{'subdir_extrametakeys'} = {};
164
165 return bless $self, $class;
166}
167
168sub begin {
169 my $self = shift (@_);
170 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
171
172 my $proc_package_name = ref $processor;
173
174 if ($proc_package_name !~ /buildproc$/) {
175
176 # Only lookup timestamp info for import.pl
177
178 my $output_dir = $processor->getoutputdir();
179 my $archives_inf = &util::filename_cat($output_dir,"archives.inf");
180
181 if ( -e $archives_inf ) {
182 $self->{'inf_timestamp'} = -M $archives_inf;
183 }
184 }
185
186 $self->SUPER::begin($pluginfo, $base_dir, $processor, $maxdocs);
187}
188
189
190# return 1 if this class might recurse using $pluginfo
191sub is_recursive {
192 my $self = shift (@_);
193
194 return 1;
195}
196
197sub get_default_block_exp {
198 my $self = shift (@_);
199
200 return 'CVS';
201}
202
203# return number of files processed, undef if can't process
204# Note that $base_dir might be "" and that $file might
205# include directories
206
207# This function passes around metadata hash structures. Metadata hash
208# structures are hashes that map from a (scalar) key (the metadata element
209# name) to either a scalar metadata value or a reference to an array of
210# such values.
211
212sub read {
213 my $self = shift (@_);
214 my ($pluginfo, $base_dir, $file, $in_metadata, $processor, $maxdocs, $total_count, $gli) = @_;
215
216 my $outhandle = $self->{'outhandle'};
217 my $verbosity = $self->{'verbosity'};
218 my $read_metadata_files = $self->{'use_metadata_files'};
219
220 # Calculate the directory name and ensure it is a directory and
221 # that it is not explicitly blocked.
222 my $dirname = $file;
223 $dirname = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
224 return undef unless (-d $dirname);
225 return 0 if ($self->{'block_exp'} ne "" && $dirname =~ /$self->{'block_exp'}/);
226
227 # check to make sure we're not reading the archives or index directory
228 my $gsdlhome = quotemeta($ENV{'GSDLHOME'});
229 if ($dirname =~ m/^$gsdlhome\/.*?\/import.*?\/(archives|index)$/) {
230 print $outhandle "RecPlug: $dirname appears to be a reference to a Greenstone collection, skipping.\n";
231 return 0;
232 }
233
234 # check to see we haven't got a cyclic path...
235 if ($dirname =~ m%(/.*){,41}%) {
236 print $outhandle "RecPlug: $dirname is 40 directories deep, is this a recursive path? if not increase constant in RecPlug.pm.\n";
237 return 0;
238 }
239
240 # check to see we haven't got a cyclic path...
241 if ($dirname =~ m%.*?import/(.+?)/import/\1.*%) {
242 print $outhandle "RecPlug: $dirname appears to be in a recursive loop...\n";
243 return 0;
244 }
245
246 if (($verbosity > 2) && ((scalar keys %$in_metadata) > 0)) {
247 print $outhandle "RecPlug: metadata passed in: ",
248 join(", ", keys %$in_metadata), "\n";
249 }
250
251 # Recur over directory contents.
252 my (@dir, $subfile);
253 my $count = 0;
254
255 print $outhandle "RecPlug: getting directory $dirname\n" if ($verbosity);
256
257 # find all the files in the directory
258 if (!opendir (DIR, $dirname)) {
259 if ($gli) {
260 print STDERR "<ProcessingError n='$file' r='Could not read directory $dirname'>\n";
261 }
262 print $outhandle "RecPlug: WARNING - couldn't read directory $dirname\n";
263 return -1; # error in processing
264 }
265 @dir = readdir (DIR);
266 closedir (DIR);
267
268 # Re-order the files in the list so any directories ending with .all are moved to the end
269 for (my $i = scalar(@dir) - 1; $i >= 0; $i--) {
270 if (-d &util::filename_cat($dirname, $dir[$i]) && $dir[$i] =~ /\.all$/) {
271 push(@dir, splice(@dir, $i, 1));
272 }
273 }
274
275 # read XML metadata files (if supplied)
276 my $additionalmetadata = 0; # is there extra metadata available?
277 my %extrametadata; # maps from filespec to extra metadata keys
278 my @extrametakeys; # keys of %extrametadata in order read
279
280 my $dirsepre = &util::get_re_dirsep();
281 my $dirsep = &util::get_dirsep();
282 my $local_dirname = $dirname;
283 $local_dirname =~ s/^$base_dir($dirsepre)//;
284 $local_dirname .= $dirsep;
285
286 if (defined $self->{'subdir_extrametakeys'}->{$local_dirname}) {
287 my $extrakeys = $self->{'subdir_extrametakeys'}->{$local_dirname};
288 foreach my $ek (@$extrakeys) {
289 my $extrakeys_re = $ek->{'re'};
290 my $extrakeys_md = $ek->{'md'};
291 push(@extrametakeys,$extrakeys_re);
292 $extrametadata{$extrakeys_re} = $extrakeys_md;
293 }
294 delete($self->{'subdir_extrametakeys'}->{$local_dirname});
295 }
296
297 if ($read_metadata_files) {
298 #read the directory "metadata.xml" file
299 my $metadatafile = &util::filename_cat ($dirname, 'metadata.xml');
300 if (-e $metadatafile) {
301 print $outhandle "RecPlug: found metadata in $metadatafile\n"
302 if ($verbosity);
303 $self->read_metadata_xml_file($metadatafile, \%extrametadata, \@extrametakeys);
304 $additionalmetadata = 1;
305 }
306 }
307
308 # apply metadata pass for each of the files in the directory
309 my $out_metadata;
310 my $num_files = scalar(@dir);
311 for (my $i = 0; $i < scalar(@dir); $i++) {
312 my $subfile = $dir[$i];
313 my $this_file_base_dir = $base_dir;
314 last if ($maxdocs != -1 && $count >= $maxdocs);
315 next if ($subfile =~ m/^\.\.?$/);
316 #next if ($read_metadata_files && $subfile =~ /metadata\.xml$/);
317
318 # Recursively read each $subfile
319 print $outhandle "RecPlug metadata recurring: $subfile\n" if ($verbosity > 2);
320
321 $count += &plugin::metadata_read ($pluginfo, $this_file_base_dir,
322 &util::filename_cat($file, $subfile),
323 $out_metadata, \@extrametakeys, \%extrametadata,
324 $processor, $maxdocs, $gli);
325 $additionalmetadata = 1;
326 }
327
328 # filter out any extrametakeys that mention subdirectories and store
329 # for later use (i.e. when that sub-directory is being processed)
330
331 foreach my $ek (@extrametakeys) {
332 my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek);
333 $extrakey_dir =~ s/\\\./\./g; # remove RE syntax
334
335 my $dirsep_re = &util::get_re_dirsep();
336
337 if ($ek =~ m/$dirsep_re/) { # specifies at least one directory
338 my $md = $extrametadata{$ek};
339
340 my $subdir_extrametakeys = $self->{'subdir_extrametakeys'};
341
342 my $subdir_rec = { 're' => $subdir_re, 'md' => $md };
343 push(@{$subdir_extrametakeys->{$extrakey_dir}},$subdir_rec);
344 }
345 }
346
347 # import each of the files in the directory
348 $count=0;
349 for (my $i = 0; $i <= scalar(@dir); $i++) {
350 # When every file in the directory has been done, pause for a moment (figuratively!)
351 # If the -recheck_directories argument hasn't been provided, stop now (default)
352 # Otherwise, re-read the contents of the directory to check for new files
353 # Any new files are added to the @dir list and are processed as normal
354 # This is necessary when documents to be indexed are specified in bibliographic DBs
355 # These files are copied/downloaded and stored in a new folder at import time
356 if ($i == $num_files) {
357 last unless $self->{'recheck_directories'};
358
359 # Re-read the files in the directory to see if there are any new files
360 last if (!opendir (DIR, $dirname));
361 my @dirnow = readdir (DIR);
362 closedir (DIR);
363
364 # We're only interested if there are more files than there were before
365 last if (scalar(@dirnow) <= scalar(@dir));
366
367 # Any new files are added to the end of @dir to get processed by the loop
368 my $j;
369 foreach my $subfilenow (@dirnow) {
370 for ($j = 0; $j < $num_files; $j++) {
371 last if ($subfilenow eq $dir[$j]);
372 }
373 if ($j == $num_files) {
374 # New file
375 push(@dir, $subfilenow);
376 }
377 }
378 # When the new files have been processed, check again
379 $num_files = scalar(@dir);
380 }
381
382 my $subfile = $dir[$i];
383 my $this_file_base_dir = $base_dir;
384 last if ($maxdocs != -1 && ($count + $total_count) >= $maxdocs);
385 next if ($subfile =~ /^\.\.?$/);
386 next if ($read_metadata_files && $subfile =~ /metadata\.xml$/);
387
388 # Follow Windows shortcuts
389 if ($subfile =~ /(?i)\.lnk$/ && $ENV{'GSDLOS'} =~ /^windows$/i) {
390 require Win32::Shortcut;
391 my $shortcut = new Win32::Shortcut(&util::filename_cat($dirname, $subfile));
392 if ($shortcut) {
393 # The file to be processed is now the target of the shortcut
394 $this_file_base_dir = "";
395 $file = "";
396 $subfile = $shortcut->Path;
397 }
398 }
399
400 # check for a symlink pointing back to a leading directory
401 if (-d "$dirname/$subfile" && -l "$dirname/$subfile") {
402 # readlink gives a "fatal error" on systems that don't implement
403 # symlinks. This assumes the the -l test above would fail on those.
404 my $linkdest=readlink "$dirname/$subfile";
405 if (!defined ($linkdest)) {
406 # system error - file not found?
407 warn "RecPlug: symlink problem - $!";
408 } else {
409 # see if link points to current or a parent directory
410 if ($linkdest =~ m@^[\./\\]+$@ ||
411 index($dirname, $linkdest) != -1) {
412 warn "RecPlug: Ignoring recursive symlink ($dirname/$subfile -> $linkdest)\n";
413 next;
414 ;
415 }
416 }
417 }
418
419 print $outhandle "RecPlug: preparing metadata for $subfile\n" if ($verbosity > 2);
420
421 # Make a copy of $in_metadata to pass to $subfile
422 $out_metadata = {};
423 &combine_metadata_structures($out_metadata, $in_metadata);
424
425 # Next add metadata read in XML files (if it is supplied)
426 if ($additionalmetadata == 1) {
427 my ($filespec, $mdref);
428 foreach $filespec (@extrametakeys) {
429 if ($subfile =~ /^$filespec$/) {
430 print $outhandle "File \"$subfile\" matches filespec \"$filespec\"\n"
431 if ($verbosity > 2);
432 $mdref = $extrametadata{$filespec};
433 &combine_metadata_structures($out_metadata, $mdref);
434 }
435 }
436 }
437
438
439 my $file_subfile = &util::filename_cat($file, $subfile);
440 my $filename_subfile
441 = &util::filename_cat($this_file_base_dir,$file_subfile);
442 if (defined $self->{'inf_timestamp'}) {
443 my $inf_timestamp = $self->{'inf_timestamp'};
444
445 if (! -d $filename_subfile) {
446 my $filename_timestamp = -M $filename_subfile;
447 if ($filename_timestamp > $inf_timestamp) {
448 # filename has been around for longer than inf
449##### print $outhandle "**** Skipping $subfile\n";
450 next;
451 }
452 }
453 }
454
455 # Recursively read each $subfile
456 print $outhandle "RecPlug recurring: $subfile\n" if ($verbosity > 2);
457
458 $count += &plugin::read ($pluginfo, $this_file_base_dir,
459 $file_subfile,
460 $out_metadata, $processor, $maxdocs, ($total_count + $count), $gli);
461 }
462
463 return $count;
464}
465
466
467
468# Read a manually-constructed metadata file and store the data
469# it contains in the $metadataref structure.
470#
471# (metadataref is a reference to a hash whose keys are filenames
472# and whose values are metadata hash structures.)
473
474sub read_metadata_xml_file {
475 my $self = shift(@_);
476 my ($filename, $metadataref, $metakeysref) = @_;
477 $self->{'metadataref'} = $metadataref;
478 $self->{'metakeysref'} = $metakeysref;
479
480 eval {
481 $self->{'parser'}->parsefile($filename);
482 };
483
484 if ($@) {
485 die "RecPlug: ERROR $filename is not a well formed metadata.xml file ($@)\n";
486 }
487}
488
489sub Doctype {
490 my ($expat, $name, $sysid, $pubid, $internal) = @_;
491
492 # allow the short-lived and badly named "GreenstoneDirectoryMetadata" files
493 # to be processed as well as the "DirectoryMetadata" files which should now
494 # be created by import.pl
495 die if ($name !~ /^(Greenstone)?DirectoryMetadata$/);
496}
497
498sub StartTag {
499 my ($expat, $element) = @_;
500
501 if ($element eq "FileSet") {
502 $self->{'saved_targets'} = [];
503 $self->{'saved_metadata'} = {};
504 }
505 elsif ($element eq "FileName") {
506 $self->{'in_filename'} = 1;
507 }
508 elsif ($element eq "Metadata") {
509 $self->{'metadata_name'} = $_{'name'};
510 if ((defined $_{'mode'}) && ($_{'mode'} eq "accumulate")) {
511 $self->{'metadata_accumulate'} = 1;
512 } else {
513 $self->{'metadata_accumulate'} = 0;
514 }
515 }
516}
517
518sub EndTag {
519 my ($expat, $element) = @_;
520
521 if ($element eq "FileSet") {
522 push (@{$self->{'metakeysref'}}, @{$self->{'saved_targets'}});
523 foreach my $target (@{$self->{'saved_targets'}}) {
524 my $file_metadata = $self->{'metadataref'}->{$target};
525 my $saved_metadata = $self->{'saved_metadata'};
526 if (!defined $file_metadata) {
527 $self->{'metadataref'}->{$target} = $saved_metadata;
528 }
529 else {
530 $self->combine_metadata_structures($file_metadata,$saved_metadata);
531 }
532 }
533 }
534 elsif ($element eq "FileName") {
535 $self->{'in_filename'} = 0;
536 }
537 elsif ($element eq "Metadata") {
538 $self->{'metadata_name'} = "";
539 }
540
541}
542
543sub store_saved_metadata
544{
545 my $self = shift(@_);
546 my ($mname,$mvalue,$md_accumulate) = @_;
547
548 if (defined $self->{'saved_metadata'}->{$mname}) {
549 if ($md_accumulate) {
550 # accumulate mode - add value to existing value(s)
551 if (ref ($self->{'saved_metadata'}->{$mname}) eq "ARRAY") {
552 push (@{$self->{'saved_metadata'}->{$mname}}, $mvalue);
553 } else {
554 $self->{'saved_metadata'}->{$mname} =
555 [$self->{'saved_metadata'}->{$mname}, $mvalue];
556 }
557 } else {
558 # override mode
559 $self->{'saved_metadata'}->{$mname} = $mvalue;
560 }
561 } else {
562 if ($md_accumulate) {
563 # accumulate mode - add value into (currently empty) array
564 $self->{'saved_metadata'}->{$mname} = [$mvalue];
565 } else {
566 # override mode
567 $self->{'saved_metadata'}->{$mname} = $mvalue;
568 }
569 }
570}
571
572
573sub Text {
574
575 if ($self->{'in_filename'}) {
576 # $_ == FileName content
577 push (@{$self->{'saved_targets'}}, $_);
578 }
579 elsif (defined ($self->{'metadata_name'}) && $self->{'metadata_name'} ne "") {
580 # $_ == Metadata content
581 my $mname = $self->{'metadata_name'};
582 my $mvalue = $_;
583 my $md_accumulate = $self->{'metadata_accumulate'};
584 $self->store_saved_metadata($mname,$mvalue,$md_accumulate);
585 }
586}
587
588# This Char function overrides the one in XML::Parser::Stream to overcome a
589# problem where $expat->{Text} is treated as the return value, slowing
590# things down significantly in some cases.
591sub Char {
592 use bytes; # Necessary to prevent encoding issues with XML::Parser 2.31+
593 $_[0]->{'Text'} .= $_[1];
594 return undef;
595}
596
597# Combine two metadata structures. Given two references to metadata
598# element structures, add every field of the second ($mdref2) to the first
599# ($mdref1).
600#
601# Afterwards $mdref1 will be updated, and $mdref2 will be unchanged.
602#
603# We have to be careful about the way we merge metadata when one metadata
604# structure is in "override" mode and one is in "merge" mode. In fact, we
605# use the mode from the second structure, $mdref2, because it is generally
606# defined later (lower in the directory structure) and is therefore more
607# "local" to the document concerned.
608#
609# Another issue is the use of references to pass metadata around. If we
610# simply copy one metadata structure reference to another, then we're
611# effectively just copyinga pointer, and changes to the new referene
612# will affect the old (copied) one also. This also applies to ARRAY
613# references used as metadata element values (hence the "clonedata"
614# function below).
615
616sub combine_metadata_structures {
617 my ($mdref1, $mdref2) = @_;
618 my ($key, $value1, $value2);
619
620 foreach $key (keys %$mdref2) {
621
622 $value1 = $mdref1->{$key};
623 $value2 = $mdref2->{$key};
624
625 # If there is no existing value for this metadata field in
626 # $mdref1, so we simply copy the value from $mdref2 over.
627 if (!defined $value1) {
628 $mdref1->{$key} = &clonedata($value2);
629 }
630 # Otherwise we have to add the new values to the existing ones.
631 # If the second structure is accumulated, then acculate all the
632 # values into the first structure
633 elsif ((ref $value2) eq "ARRAY") {
634 # If the first metadata element is a scalar we have to
635 # convert it into an array before we add anything more.
636 if ((ref $value1) ne 'ARRAY') {
637 $mdref1->{$key} = [$value1];
638 $value1 = $mdref1->{$key};
639 }
640 # Now add the value(s) from the second array to the first
641 $value2 = &clonedata($value2);
642 push @$value1, @$value2;
643 }
644 # Finally, If the second structure is not an array erference, we
645 # know it is in override mode, so override the first structure.
646 else {
647 $mdref1->{$key} = &clonedata($value2);
648 }
649 }
650}
651
652
653# Make a "cloned" copy of a metadata value.
654# This is trivial for a simple scalar value,
655# but not for an array reference.
656
657sub clonedata {
658 my ($value) = @_;
659 my $result;
660
661 if ((ref $value) eq 'ARRAY') {
662 $result = [];
663 foreach my $item (@$value) {
664 push @$result, $item;
665 }
666 } else {
667 $result = $value;
668 }
669 return $result;
670}
671
672
6731;
Note: See TracBrowser for help on using the repository browser.