Changeset 15117


Ignore:
Timestamp:
2008-03-20T20:54:49+13:00 (14 years ago)
Author:
ak19
Message:

Dr Bainbridge made some changes to tidy up the code (replaced file global params with args and removed unnecessary statements)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/acronym.pm

    r7645 r15117  
    5858my @acronym_list = ();
    5959
    60 #the file to collate acronyms into
    61 my $acronym_accumulate_file = $ENV{'GSDLCOLLECTDIR'} . "/etc/acronym_definitions.pm";
    62 my $acronym_options_file = $ENV{'GSDLCOLLECTDIR'} . "/etc/acronym_options.pm";
    6360
    6461my %acronyms_found_in_collection = ();
     
    8784    my $local_allow_all_caps = $allow_all_caps;
    8885    my @local_stop_words = @stop_words;
    89     my $local_acronym_accumulate_file = $acronym_accumulate_file;
    90    
    91    
     86   
     87   
     88    # the file to collate acronyms into
     89
     90    my $def_acronym_acc_file_pm = '&util::filename_cat($ENV{\'GSDLCOLLECTDIR\'}, "etc","acronym_definitions.pm");';
     91    my $acronym_accumulate_file = eval { $def_acronym_acc_file_pm };
     92    my $acronym_options_file = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},"etc","acronym_options.pm");
     93
     94
    9295    my $file_text = "";
    9396    if (open ACRONYM_HANDLE, "<$acronym_options_file")
     
    99102    print STDERR "failed to open $acronym_options_file\n";
    100103    open ACRONYM_HANDLE, ">$acronym_options_file\n";
     104    print ACRONYM_HANDLE "use util;\n";
    101105    print ACRONYM_HANDLE "#Config file for acronym extraction. EDIT THIS FILE, it should\n";
    102106    print ACRONYM_HANDLE "#not be overridden by the software. It's read by GSDL using perl's\n";
     
    129133    print ACRONYM_HANDLE "\n";
    130134    print ACRONYM_HANDLE "#the file to collate acronyms into\n";
    131     print ACRONYM_HANDLE "\$local_acronym_accumulate_file = \$ENV{'GSDLCOLLECTDIR'} . \"/etc/acronym_definitions.pm\";\n";
     135    print ACRONYM_HANDLE "\$acronym_accumulate_file = $def_acronym_acc_file_pm\n";
    132136    print ACRONYM_HANDLE "\n";
    133137    print ACRONYM_HANDLE "# any acronym definitions which should always be marked up can be copied here\n";
     
    153157    $allow_all_caps = $local_allow_all_caps;
    154158    @stop_words = @local_stop_words;
    155    
    156     $local_acronym_accumulate_file = $local_acronym_accumulate_file;
    157    
    158 
    159     &read_all_acronyms_from_file();
     159       
     160
     161    &read_all_acronyms_from_file($acronym_accumulate_file);
    160162#    rename $acronym_file, $acronym_file . "." . int(rand (2<<7)).
    161163#   int(rand (2<<7)). int(rand (2<<7)). int(rand (2<<7));
     
    187189#eval a file of accumulated acronyms
    188190sub read_all_acronyms_from_file {
    189    
     191    my ($acronym_accumulate_file) = @_;
     192
    190193    my $file_text = " ";
    191194    if (open ACRONYM_HANDLE, "<$acronym_accumulate_file")
Note: See TracChangeset for help on using the changeset viewer.