Changeset 15895


Ignore:
Timestamp:
2008-06-06T11:19:09+12:00 (16 years ago)
Author:
mdewsnip
Message:

Added "use strict" to one more file, then fixed all the problems identified.

File:
1 edited

Legend:

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

    r15894 r15895  
    33##use BasPlug; ## no, DON'T use BasPlug, BasPlug uses us....
    44use sorttools;
     5use strict;
    56use util;
    67
     
    7172    #get the text of the document, the "document object" concerned,
    7273    #and the current section within the document
    73     local ($text, $doc, $cursection, $keep_bib, $max_year, $max_century) = @_;
     74    my ($text, $doc, $cursection, $keep_bib, $max_year, $max_century) = @_;
    7475   
    7576    #format a prechristian maximum century value to be negative so that it can
     
    8384    }
    8485   
    85     local $extr = &remove_excess($text);   
     86    my $extr = &remove_excess($text);   
    8687    #print "EXTRACTION TEXT:\n $extr";
    8788    $extr = &remove_tags($extr);
     
    9192 
    9293
    93     local @datelist = ();
     94    my @datelist = ();
    9495    while($extr =~ m!($range)|($millenium)|($qualified)|($centurydate)|($tri_digit)!i)
    9596    {
     
    101102            {
    102103
    103                 local $date = $fulldate; if($date =~ /\d+/) {$date = $&;}
     104                my $date = $fulldate; if($date =~ /\d+/) {$date = $&;}
    104105                else
    105106                {
     
    112113                    #if it BC, make it negative
    113114                    $date = &convert_bc($fulldate,$date);
    114                     $end = $date + 99;
    115                     @century = ($date..$end);
     115                    my $end = $date + 99;
     116                    my @century = ($date..$end);
    116117                    @datelist = (@datelist,@century);
    117118                }
     
    124125            my @addlist = ();
    125126            #print "Range: $fulldate\n";
    126             $fullfirst = $`;
    127             $fullsecond = $';
    128             $fullfirst =~ /\d+/; $first = $&;
    129             $fullsecond =~ /\d+/; $second = $&;
    130             $len1 = length($first);
    131             $len2 = length($second);
     127            my $fullfirst = $`;
     128            my $fullsecond = $';
     129            $fullfirst =~ /\d+/;
     130        my $first = $&;
     131            $fullsecond =~ /\d+/;
     132        my $second = $&;
     133            my $len1 = length($first);
     134            my $len2 = length($second);
    132135            $second = (substr($first,0,($len1-$len2))).$second;
    133136            $first = &convert_bc($fullfirst,$first);
     
    151154        @datelist = sort { $a <=> $b } @datelist;
    152155        @datelist = &post_process($max_year, @datelist);
    153         foreach $date (@datelist)
     156        foreach my $date (@datelist)
    154157        {
    155158            if($date>0){
     
    162165}
    163166sub convert_bc {
    164     local ($full,$num) = @_;
     167    my ($full,$num) = @_;
    165168    if ($full =~ /B/) { $num *= -1; }
    166169    $num;
     
    168171
    169172sub post_process {
    170     local ($max_year, @list) = @_;
    171     @cleanlist = ();
    172     $prev = 0;
    173     foreach $e (@list) {
     173    my ($max_year, @list) = @_;
     174    my @cleanlist = ();
     175    my $prev = 0;
     176    foreach my $e (@list) {
    174177        if ($e!=$prev && $e <= $max_year) {
    175178            push(@cleanlist, $e);
     
    185188#contain date lookalikes
    186189sub remove_tags {
    187     local ($tmp) = @_;
     190    my ($tmp) = @_;
    188191   
    189     local $parsed = "";
     192    my $parsed = "";
    190193    #while there is still text to be parsed and tags are still found
    191194    while($tmp=~ m!<([^>])*(>|$)! && $tmp ne "")
     
    200203
    201204sub remove_excess {
    202     local ($tmp) = @_;
    203     local $parsed = "";
     205    my ($tmp) = @_;
     206    my $parsed = "";
    204207   
    205208
     
    213216        {
    214217            $parsed .= $`;
    215             $storage = $&;
     218            my $storage = $&;
    216219            $tmp = $';
    217220            #match the pattern which indicates most recent alteration
     
    235238
    236239sub remove_biblio{
    237     local ($tmp) = @_;
    238     local $parsed = "";
     240    my ($tmp) = @_;
     241    my $parsed = "";
    239242   
    240243    if($tmp =~ m!$bibheader!i)
     
    259262            {
    260263               
    261                 local $date = $&;
     264                my $date = $&;
    262265                if($parsed =~ m!((\d)($Ord)$)|(($shortmth)$)|(($longmth)$)!i)
    263266                {
Note: See TracChangeset for help on using the changeset viewer.