source: trunk/gsdl/perllib/scriptutil.pm@ 10418

Last change on this file since 10418 was 10418, checked in by kjdon, 19 years ago

new module with some global script functions. couldn't add the method into util, cos need to use gsprintf, adn it wouldn't work

  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1###########################################################################
2#
3# scriptutil.pm -- various useful utilities for the scripts
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
26package scriptutil;
27no strict 'subs'; # allow barewords (eg STDERR) as function arguments
28no strict 'refs'; # ...but allow filehandles to be variables and vice versa
29
30use gsprintf 'gsprintf';
31
32# returns $removeold, $keepold
33sub check_removeold_and_keepold {
34
35 my ($removeold, $keepold, $dir, $collectcfg) = @_;
36
37 if ($keepold && $removeold) {
38 gsprintf(STDERR, "{scripts.both_old_options}\n", $dir);
39 sleep(3); #just in case
40 return (1,0);
41
42 }
43
44 if (!$keepold && !$removeold) {
45 # we only look at config file options if we dont have these on the command line
46 if (defined $collectcfg->{'removeold'} && $collectcfg->{'removeold'} =~ /^true$/i ) {
47 $removeold = 1;
48 } elsif (defined $collectcfg->{'keepold'} && $collectcfg->{'keepold'} =~ /^true$/i) {
49 $keepold = 1;
50 }
51 }
52 if (!$keepold && !$removeold) {
53 gsprintf(STDERR, "{scripts.no_old_options} \n", $dir);
54 sleep(3); #just in case
55 return (1,0);
56 }
57
58 return ($removeold, $keepold);
59
60}
61
621;
Note: See TracBrowser for help on using the repository browser.