Changeset 10339

Show
Ignore:
Timestamp:
28.07.2005 11:52:21 (15 years ago)
Author:
kjdon
Message:

uses new parse2 arg parsing, added 'use strict'

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/exportcol.pl

    r10225 r10339  
    3131} 
    3232 
     33use strict; 
     34no strict 'refs'; # allow filehandles to be variables and vice versa 
     35no strict 'subs'; # allow barewords (eg STDERR) as function arguments 
     36 
    3337use util; 
    34 use parsargv; 
     38use parse2; 
    3539use printusage; 
    3640 
     
    3943    'desc' => "{scripts.language}", 
    4044    'type' => "string", 
    41     'reqd' => "no" }, 
    42       { 'name' => "xml", 
    43     'desc' => "{scripts.xml}", 
    44     'type' => "flag", 
    4545    'reqd' => "no" }, 
    4646      { 'name' => "out", 
     
    6262    'type' => "string", 
    6363    'deft' => "exported_collections", 
    64     'reqd' => "no" } ]; 
     64    'reqd' => "no" }, 
     65      { 'name' => "xml", 
     66    'desc' => "{scripts.xml}", 
     67    'type' => "flag", 
     68    'reqd' => "no", 
     69    'hiddengli' => "yes" }, 
     70      { 'name' => "gli", 
     71    'desc' => "", 
     72    'type' => "flag", 
     73    'reqd' => "no", 
     74    'hiddengli' => "yes" }, 
     75 
     76      ]; 
    6577 
    6678my $options = { 'name' => "exportcol.pl", 
     
    7789 
    7890sub main { 
    79     my ($language, $out, $cdname, $gli); 
     91    my ($language, $out, $cdname, $cddir, $gli); 
    8092 
    8193    my $xml = 0; 
    82     my $no_netscape = 0; 
    83  
    84     if (!parsargv::parse(\@ARGV, 
    85              'language/.*/', \$language, 
    86              'out/.*/STDERR', \$out, 
    87              'cdname/.*/Greenstone Collections', \$cdname, 
    88              'cddir/.*/exported_collections', \$cddir, 
    89              'gli', \$gli, 
    90              'nonetscape', \$no_netscape, 
    91              q^xml^, \$xml)) { 
    92  
    93     &PrintUsage::print_txt_usage($options, "{exportcol.params}"); 
    94     die "\n"; 
    95     } 
    96  
    97     my $use_netscape = ($no_netscape) ? 0 : 1; 
     94    my $nonetscape = 0; 
     95 
     96    my $hashParsingResult = {}; 
     97    my $blnParseFailed = "false"; 
     98    # parse options 
     99    my $intArgLeftinAfterParsing = parse2::parse(\@ARGV,$arguments,$hashParsingResult,"allow_extra_options"); 
     100    # don't care how many args are left - can have multiple collection names 
     101    foreach my $strVariable (keys %$hashParsingResult) 
     102    { 
     103    eval "\$$strVariable = \$hashParsingResult->{\"\$strVariable\"}"; 
     104    } 
     105     
     106    # If $language has been specified, load the appropriate resource bundle 
     107    # (Otherwise, the default resource bundle will be loaded automatically) 
     108    if ($language && $language =~ /\S/) { 
     109    &gsprintf::load_language_specific_resource_bundle($language); 
     110    } 
     111     
     112    if ($xml) { 
     113        &PrintUsage::print_xml_usage($options); 
     114    print "\n"; 
     115    return; 
     116    } 
     117     
     118    if ($gli) { # the gli wants strings to be in UTF-8 
     119    &gsprintf::output_strings_in_UTF8;  
     120    } 
     121     
     122    my $use_netscape = ($nonetscape) ? 0 : 1; 
    98123 
    99124    # If $language has been specified, load the appropriate resource bundle 
     
    112137    } 
    113138 
    114 # No longer needed now -cddir flag also included (with default)     
    115 #    my $dirname="";  
    116 #    if ($cdname eq "") { 
    117 #   $cdname = "Greenstone Collections"; 
    118 #   $dirname = "exported_collections"; 
    119 #    } else { 
    120 #   $dirname = $cdname; 
    121 #   $dirname =~ s/\s//g; 
    122 #   $dirname = "exported_".$dirname; 
    123 #    } 
    124  
    125139    my @coll_list = @ARGV; 
    126  
     140     
    127141    if (not @coll_list) { # empty list 
    128142    &PrintUsage::print_txt_usage($options, "{exportcol.params}"); 
     
    148162    # check each collection 
    149163    my @valid_coll_list = (); 
    150     foreach $c (@coll_list) { 
     164    foreach my $c (@coll_list) { 
    151165    my $colldir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $c); 
    152166    if (! -d $colldir) { 
     
    217231    print MANIFESTCFG "database:\n"; 
    218232    print MANIFESTCFG '  etc '; 
    219     foreach $c (@valid_coll_list) { 
     233    foreach my $c (@valid_coll_list) { 
    220234    print MANIFESTCFG "collect\\$c\\index\\text\\$c.ldb "; 
    221235    } 
     
    296310 
    297311    # copy the collections over  
    298     foreach $c (@valid_coll_list) { 
     312    foreach my $c (@valid_coll_list) { 
    299313    #old directories 
    300314    my $colldir = &util::filename_cat ($ENV{'GSDLHOME'}, "collect", $c); 
     
    316330    open INFILE, "<$collectcfg"; 
    317331    open OUTFILE, ">$collectcfg.tmp"; 
     332    my $line; 
    318333    while ($line = <INFILE>) { 
    319334        if ($line =~ /^\s*public\s+false/) { 
     
    336351    my $successcolls = ""; 
    337352    my $first = 1; 
    338     foreach $c (@valid_coll_list) { 
     353    foreach my $c (@valid_coll_list) { 
    339354    if ($first) { 
    340355        $first=0;