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

Last change on this file since 11919 was 11919, checked in by mdewsnip, 18 years ago

Fixed some metadata_read code that was obviously not tested on Windows.

  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 21.5 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;
101use strict;
102no strict 'refs';
103
104BEGIN {
105 @RecPlug::ISA = ('BasPlug');
106 unshift (@INC, "$ENV{'GSDLHOME'}/perllib/cpan");
107}
108
109use XMLParser;
110
111my $arguments =
112 [ { 'name' => "block_exp",
113 'desc' => "{BasPlug.block_exp}",
114 'type' => "regexp",
115 'deft' => &get_default_block_exp(),
116 'reqd' => "no" },
117 { 'name' => "use_metadata_files",
118 'desc' => "{RecPlug.use_metadata_files}",
119 'type' => "flag",
120 'reqd' => "no" },
121 { 'name' => "recheck_directories",
122 'desc' => "{RecPlug.recheck_directories}",
123 'type' => "flag",
124 'reqd' => "no" } ];
125
126my $options = { 'name' => "RecPlug",
127 'desc' => "{RecPlug.desc}",
128 'abstract' => "no",
129 'inherits' => "yes",
130 'args' => $arguments };
131
132
133my ($self);
134
135sub new {
136 my ($class) = shift (@_);
137 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
138 push(@$pluginlist, $class);
139
140 if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
141 if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
142
143 $self = (defined $hashArgOptLists)? new BasPlug($pluginlist,$inputargs,$hashArgOptLists): new BasPlug($pluginlist,$inputargs);
144 if ($self->{'use_metadata_files'}) {
145 # create XML::Parser object for parsing metadata.xml files
146 my $parser = new XML::Parser('Style' => 'Stream',
147 'Handlers' => {'Char' => \&Char,
148 'Doctype' => \&Doctype
149 });
150
151 $self->{'parser'} = $parser;
152 $self->{'in_filename'} = 0;
153 }
154
155 $self->{'subdir_extrametakeys'} = {};
156
157 return bless $self, $class;
158}
159
160sub begin {
161 my $self = shift (@_);
162 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
163
164 my $proc_package_name = ref $processor;
165
166 if ($proc_package_name !~ /buildproc$/) {
167
168 # Only lookup timestamp info for import.pl
169
170 my $output_dir = $processor->getoutputdir();
171 my $archives_inf = &util::filename_cat($output_dir,"archives.inf");
172
173 if ( -e $archives_inf ) {
174 $self->{'inf_timestamp'} = -M $archives_inf;
175 }
176 }
177
178 $self->SUPER::begin($pluginfo, $base_dir, $processor, $maxdocs);
179}
180
181
182# return 1 if this class might recurse using $pluginfo
183sub is_recursive {
184 my $self = shift (@_);
185
186 return 1;
187}
188
189sub get_default_block_exp {
190 my $self = shift (@_);
191
192 return 'CVS';
193}
194
195# return number of files processed, undef if can't process
196# Note that $base_dir might be "" and that $file might
197# include directories
198
199# This function passes around metadata hash structures. Metadata hash
200# structures are hashes that map from a (scalar) key (the metadata element
201# name) to either a scalar metadata value or a reference to an array of
202# such values.
203
204sub read {
205 my $self = shift (@_);
206 my ($pluginfo, $base_dir, $file, $in_metadata, $processor, $maxdocs, $total_count, $gli) = @_;
207
208 my $outhandle = $self->{'outhandle'};
209 my $verbosity = $self->{'verbosity'};
210 my $read_metadata_files = $self->{'use_metadata_files'};
211
212 # Calculate the directory name and ensure it is a directory and
213 # that it is not explicitly blocked.
214 my $dirname = $file;
215 $dirname = &util::filename_cat ($base_dir, $file) if $base_dir =~ /\w/;
216 return undef unless (-d $dirname);
217 return 0 if ($self->{'block_exp'} ne "" && $dirname =~ /$self->{'block_exp'}/);
218
219 # check to make sure we're not reading the archives or index directory
220 my $gsdlhome = quotemeta($ENV{'GSDLHOME'});
221 if ($dirname =~ m/^$gsdlhome\/.*?\/import.*?\/(archives|index)$/) {
222 print $outhandle "RecPlug: $dirname appears to be a reference to a Greenstone collection, skipping.\n";
223 return 0;
224 }
225
226 # check to see we haven't got a cyclic path...
227 if ($dirname =~ m%(/.*){,41}%) {
228 print $outhandle "RecPlug: $dirname is 40 directories deep, is this a recursive path? if not increase constant in RecPlug.pm.\n";
229 return 0;
230 }
231
232 # check to see we haven't got a cyclic path...
233 if ($dirname =~ m%.*?import/(.+?)/import/\1.*%) {
234 print $outhandle "RecPlug: $dirname appears to be in a recursive loop...\n";
235 return 0;
236 }
237
238 if (($verbosity > 2) && ((scalar keys %$in_metadata) > 0)) {
239 print $outhandle "RecPlug: metadata passed in: ",
240 join(", ", keys %$in_metadata), "\n";
241 }
242
243 # Recur over directory contents.
244 my (@dir, $subfile);
245 my $count = 0;
246
247 print $outhandle "RecPlug: getting directory $dirname\n" if ($verbosity);
248
249 # find all the files in the directory
250 if (!opendir (DIR, $dirname)) {
251 if ($gli) {
252 print STDERR "<ProcessingError n='$file' r='Could not read directory $dirname'>\n";
253 }
254 print $outhandle "RecPlug: WARNING - couldn't read directory $dirname\n";
255 return -1; # error in processing
256 }
257 @dir = readdir (DIR);
258 closedir (DIR);
259
260 # Re-order the files in the list so any directories ending with .all are moved to the end
261 for (my $i = scalar(@dir) - 1; $i >= 0; $i--) {
262 if (-d &util::filename_cat($dirname, $dir[$i]) && $dir[$i] =~ /\.all$/) {
263 push(@dir, splice(@dir, $i, 1));
264 }
265 }
266
267 # read XML metadata files (if supplied)
268 my $additionalmetadata = 0; # is there extra metadata available?
269 my %extrametadata; # maps from filespec to extra metadata keys
270 my @extrametakeys; # keys of %extrametadata in order read
271
272 my $os_dirsep = &util::get_os_dirsep();
273 my $dirsep = &util::get_dirsep();
274 my $base_dir_regexp = $base_dir;
275 $base_dir_regexp =~ s/\//$os_dirsep/g;
276 my $local_dirname = $dirname;
277 $local_dirname =~ s/^$base_dir_regexp($os_dirsep)//;
278 $local_dirname .= $dirsep;
279
280 if (defined $self->{'subdir_extrametakeys'}->{$local_dirname}) {
281 my $extrakeys = $self->{'subdir_extrametakeys'}->{$local_dirname};
282 foreach my $ek (@$extrakeys) {
283 my $extrakeys_re = $ek->{'re'};
284 my $extrakeys_md = $ek->{'md'};
285 push(@extrametakeys,$extrakeys_re);
286 $extrametadata{$extrakeys_re} = $extrakeys_md;
287 }
288 delete($self->{'subdir_extrametakeys'}->{$local_dirname});
289 }
290
291 if ($read_metadata_files) {
292 #read the directory "metadata.xml" file
293 my $metadatafile = &util::filename_cat ($dirname, 'metadata.xml');
294 if (-e $metadatafile) {
295 print $outhandle "RecPlug: found metadata in $metadatafile\n"
296 if ($verbosity);
297 $self->read_metadata_xml_file($metadatafile, \%extrametadata, \@extrametakeys);
298 $additionalmetadata = 1;
299 }
300 }
301
302 # apply metadata pass for each of the files in the directory
303 my $out_metadata;
304 my $num_files = scalar(@dir);
305 for (my $i = 0; $i < scalar(@dir); $i++) {
306 my $subfile = $dir[$i];
307 my $this_file_base_dir = $base_dir;
308 last if ($maxdocs != -1 && $count >= $maxdocs);
309 next if ($subfile =~ m/^\.\.?$/);
310 #next if ($read_metadata_files && $subfile =~ /metadata\.xml$/);
311
312 # Recursively read each $subfile
313 print $outhandle "RecPlug metadata recurring: $subfile\n" if ($verbosity > 2);
314
315 $count += &plugin::metadata_read ($pluginfo, $this_file_base_dir,
316 &util::filename_cat($file, $subfile),
317 $out_metadata, \@extrametakeys, \%extrametadata,
318 $processor, $maxdocs, $gli);
319 $additionalmetadata = 1;
320 }
321
322 # filter out any extrametakeys that mention subdirectories and store
323 # for later use (i.e. when that sub-directory is being processed)
324
325 foreach my $ek (@extrametakeys) {
326 my ($subdir_re,$extrakey_dir) = &File::Basename::fileparse($ek);
327 $extrakey_dir =~ s/\\\./\./g; # remove RE syntax
328
329 my $dirsep_re = &util::get_re_dirsep();
330 if ($ek =~ m/$dirsep_re/) { # specifies at least one directory
331 my $md = $extrametadata{$ek};
332
333 my $subdir_extrametakeys = $self->{'subdir_extrametakeys'};
334
335 my $subdir_rec = { 're' => $subdir_re, 'md' => $md };
336 push(@{$subdir_extrametakeys->{$extrakey_dir}},$subdir_rec);
337 }
338 }
339
340 # import each of the files in the directory
341 $count=0;
342 for (my $i = 0; $i <= scalar(@dir); $i++) {
343 # When every file in the directory has been done, pause for a moment (figuratively!)
344 # If the -recheck_directories argument hasn't been provided, stop now (default)
345 # Otherwise, re-read the contents of the directory to check for new files
346 # Any new files are added to the @dir list and are processed as normal
347 # This is necessary when documents to be indexed are specified in bibliographic DBs
348 # These files are copied/downloaded and stored in a new folder at import time
349 if ($i == $num_files) {
350 last unless $self->{'recheck_directories'};
351
352 # Re-read the files in the directory to see if there are any new files
353 last if (!opendir (DIR, $dirname));
354 my @dirnow = readdir (DIR);
355 closedir (DIR);
356
357 # We're only interested if there are more files than there were before
358 last if (scalar(@dirnow) <= scalar(@dir));
359
360 # Any new files are added to the end of @dir to get processed by the loop
361 my $j;
362 foreach my $subfilenow (@dirnow) {
363 for ($j = 0; $j < $num_files; $j++) {
364 last if ($subfilenow eq $dir[$j]);
365 }
366 if ($j == $num_files) {
367 # New file
368 push(@dir, $subfilenow);
369 }
370 }
371 # When the new files have been processed, check again
372 $num_files = scalar(@dir);
373 }
374
375 my $subfile = $dir[$i];
376 my $this_file_base_dir = $base_dir;
377 last if ($maxdocs != -1 && ($count + $total_count) >= $maxdocs);
378 next if ($subfile =~ /^\.\.?$/);
379 next if ($read_metadata_files && $subfile =~ /metadata\.xml$/);
380
381 # Follow Windows shortcuts
382 if ($subfile =~ /(?i)\.lnk$/ && $ENV{'GSDLOS'} =~ /^windows$/i) {
383 require Win32::Shortcut;
384 my $shortcut = new Win32::Shortcut(&util::filename_cat($dirname, $subfile));
385 if ($shortcut) {
386 # The file to be processed is now the target of the shortcut
387 $this_file_base_dir = "";
388 $file = "";
389 $subfile = $shortcut->Path;
390 }
391 }
392
393 # check for a symlink pointing back to a leading directory
394 if (-d "$dirname/$subfile" && -l "$dirname/$subfile") {
395 # readlink gives a "fatal error" on systems that don't implement
396 # symlinks. This assumes the the -l test above would fail on those.
397 my $linkdest=readlink "$dirname/$subfile";
398 if (!defined ($linkdest)) {
399 # system error - file not found?
400 warn "RecPlug: symlink problem - $!";
401 } else {
402 # see if link points to current or a parent directory
403 if ($linkdest =~ m@^[\./\\]+$@ ||
404 index($dirname, $linkdest) != -1) {
405 warn "RecPlug: Ignoring recursive symlink ($dirname/$subfile -> $linkdest)\n";
406 next;
407 ;
408 }
409 }
410 }
411
412 print $outhandle "RecPlug: preparing metadata for $subfile\n" if ($verbosity > 2);
413
414 # Make a copy of $in_metadata to pass to $subfile
415 $out_metadata = {};
416 &combine_metadata_structures($out_metadata, $in_metadata);
417
418 # Next add metadata read in XML files (if it is supplied)
419 if ($additionalmetadata == 1) {
420
421 my ($filespec, $mdref);
422 foreach $filespec (@extrametakeys) {
423 if ($subfile =~ /^$filespec$/) {
424 print $outhandle "File \"$subfile\" matches filespec \"$filespec\"\n"
425 if ($verbosity > 2);
426 $mdref = $extrametadata{$filespec};
427 &combine_metadata_structures($out_metadata, $mdref);
428 }
429 }
430 }
431
432
433 my $file_subfile = &util::filename_cat($file, $subfile);
434 my $filename_subfile
435 = &util::filename_cat($this_file_base_dir,$file_subfile);
436 if (defined $self->{'inf_timestamp'}) {
437 my $inf_timestamp = $self->{'inf_timestamp'};
438
439 if (! -d $filename_subfile) {
440 my $filename_timestamp = -M $filename_subfile;
441 if ($filename_timestamp > $inf_timestamp) {
442 # filename has been around for longer than inf
443##### print $outhandle "**** Skipping $subfile\n";
444 next;
445 }
446 }
447 }
448
449 # Recursively read each $subfile
450 print $outhandle "RecPlug recurring: $subfile\n" if ($verbosity > 2);
451
452 $count += &plugin::read ($pluginfo, $this_file_base_dir,
453 $file_subfile,
454 $out_metadata, $processor, $maxdocs, ($total_count + $count), $gli);
455 }
456
457 return $count;
458}
459
460
461
462# Read a manually-constructed metadata file and store the data
463# it contains in the $metadataref structure.
464#
465# (metadataref is a reference to a hash whose keys are filenames
466# and whose values are metadata hash structures.)
467
468sub read_metadata_xml_file {
469 my $self = shift(@_);
470 my ($filename, $metadataref, $metakeysref) = @_;
471 $self->{'metadataref'} = $metadataref;
472 $self->{'metakeysref'} = $metakeysref;
473
474 eval {
475 $self->{'parser'}->parsefile($filename);
476 };
477
478 if ($@) {
479 die "RecPlug: ERROR $filename is not a well formed metadata.xml file ($@)\n";
480 }
481}
482
483sub Doctype {
484 my ($expat, $name, $sysid, $pubid, $internal) = @_;
485
486 # allow the short-lived and badly named "GreenstoneDirectoryMetadata" files
487 # to be processed as well as the "DirectoryMetadata" files which should now
488 # be created by import.pl
489 die if ($name !~ /^(Greenstone)?DirectoryMetadata$/);
490}
491
492sub StartTag {
493 my ($expat, $element) = @_;
494
495 if ($element eq "FileSet") {
496 $self->{'saved_targets'} = [];
497 $self->{'saved_metadata'} = {};
498 }
499 elsif ($element eq "FileName") {
500 $self->{'in_filename'} = 1;
501 }
502 elsif ($element eq "Metadata") {
503 $self->{'metadata_name'} = $_{'name'};
504 if ((defined $_{'mode'}) && ($_{'mode'} eq "accumulate")) {
505 $self->{'metadata_accumulate'} = 1;
506 } else {
507 $self->{'metadata_accumulate'} = 0;
508 }
509 }
510}
511
512sub EndTag {
513 my ($expat, $element) = @_;
514
515 if ($element eq "FileSet") {
516 push (@{$self->{'metakeysref'}}, @{$self->{'saved_targets'}});
517 foreach my $target (@{$self->{'saved_targets'}}) {
518 my $file_metadata = $self->{'metadataref'}->{$target};
519 my $saved_metadata = $self->{'saved_metadata'};
520 if (!defined $file_metadata) {
521 $self->{'metadataref'}->{$target} = $saved_metadata;
522 }
523 else {
524 $self->combine_metadata_structures($file_metadata,$saved_metadata);
525 }
526 }
527 }
528 elsif ($element eq "FileName") {
529 $self->{'in_filename'} = 0;
530 }
531 elsif ($element eq "Metadata") {
532 $self->{'metadata_name'} = "";
533 }
534
535}
536
537sub store_saved_metadata
538{
539 my $self = shift(@_);
540 my ($mname,$mvalue,$md_accumulate) = @_;
541
542 if (defined $self->{'saved_metadata'}->{$mname}) {
543 if ($md_accumulate) {
544 # accumulate mode - add value to existing value(s)
545 if (ref ($self->{'saved_metadata'}->{$mname}) eq "ARRAY") {
546 push (@{$self->{'saved_metadata'}->{$mname}}, $mvalue);
547 } else {
548 $self->{'saved_metadata'}->{$mname} =
549 [$self->{'saved_metadata'}->{$mname}, $mvalue];
550 }
551 } else {
552 # override mode
553 $self->{'saved_metadata'}->{$mname} = $mvalue;
554 }
555 } else {
556 if ($md_accumulate) {
557 # accumulate mode - add value into (currently empty) array
558 $self->{'saved_metadata'}->{$mname} = [$mvalue];
559 } else {
560 # override mode
561 $self->{'saved_metadata'}->{$mname} = $mvalue;
562 }
563 }
564}
565
566
567sub Text {
568
569 if ($self->{'in_filename'}) {
570 # $_ == FileName content
571 push (@{$self->{'saved_targets'}}, $_);
572 }
573 elsif (defined ($self->{'metadata_name'}) && $self->{'metadata_name'} ne "") {
574 # $_ == Metadata content
575 my $mname = $self->{'metadata_name'};
576 my $mvalue = $_;
577 my $md_accumulate = $self->{'metadata_accumulate'};
578 $self->store_saved_metadata($mname,$mvalue,$md_accumulate);
579 }
580}
581
582# This Char function overrides the one in XML::Parser::Stream to overcome a
583# problem where $expat->{Text} is treated as the return value, slowing
584# things down significantly in some cases.
585sub Char {
586 use bytes; # Necessary to prevent encoding issues with XML::Parser 2.31+
587 $_[0]->{'Text'} .= $_[1];
588 return undef;
589}
590
591# Combine two metadata structures. Given two references to metadata
592# element structures, add every field of the second ($mdref2) to the first
593# ($mdref1).
594#
595# Afterwards $mdref1 will be updated, and $mdref2 will be unchanged.
596#
597# We have to be careful about the way we merge metadata when one metadata
598# structure is in "override" mode and one is in "merge" mode. In fact, we
599# use the mode from the second structure, $mdref2, because it is generally
600# defined later (lower in the directory structure) and is therefore more
601# "local" to the document concerned.
602#
603# Another issue is the use of references to pass metadata around. If we
604# simply copy one metadata structure reference to another, then we're
605# effectively just copyinga pointer, and changes to the new referene
606# will affect the old (copied) one also. This also applies to ARRAY
607# references used as metadata element values (hence the "clonedata"
608# function below).
609
610sub combine_metadata_structures {
611 my ($mdref1, $mdref2) = @_;
612 my ($key, $value1, $value2);
613
614 foreach $key (keys %$mdref2) {
615
616 $value1 = $mdref1->{$key};
617 $value2 = $mdref2->{$key};
618
619 # If there is no existing value for this metadata field in
620 # $mdref1, so we simply copy the value from $mdref2 over.
621 if (!defined $value1) {
622 $mdref1->{$key} = &clonedata($value2);
623 }
624 # Otherwise we have to add the new values to the existing ones.
625 # If the second structure is accumulated, then acculate all the
626 # values into the first structure
627 elsif ((ref $value2) eq "ARRAY") {
628 # If the first metadata element is a scalar we have to
629 # convert it into an array before we add anything more.
630 if ((ref $value1) ne 'ARRAY') {
631 $mdref1->{$key} = [$value1];
632 $value1 = $mdref1->{$key};
633 }
634 # Now add the value(s) from the second array to the first
635 $value2 = &clonedata($value2);
636 push @$value1, @$value2;
637 }
638 # Finally, If the second structure is not an array erference, we
639 # know it is in override mode, so override the first structure.
640 else {
641 $mdref1->{$key} = &clonedata($value2);
642 }
643 }
644}
645
646
647# Make a "cloned" copy of a metadata value.
648# This is trivial for a simple scalar value,
649# but not for an array reference.
650
651sub clonedata {
652 my ($value) = @_;
653 my $result;
654
655 if ((ref $value) eq 'ARRAY') {
656 $result = [];
657 foreach my $item (@$value) {
658 push @$result, $item;
659 }
660 } else {
661 $result = $value;
662 }
663 return $result;
664}
665
666
6671;
Note: See TracBrowser for help on using the repository browser.