%unreported_case_list = ( '30/11/90, cp654/88' => '1' );
&DoSomething('In Bradburn v Harris 30/11/90, Fisher J, HC Auckland CP654/88 Fisher J was dealing with a counterclaim for interest under two vendor mortgages.');
sub DoSomething {
my($line) = @_;
my($new_line,
$citation,
$start_of_line,
$jump_destination) = ('','','','','');
DEBUG('c',"IN DoSomething\n");
while ( $line =~ s{^ ( .*? ) < FD:"Case \s Citation" > ( .+? ) FD:"Case \s Citation" > }{}xi ) {
$start_of_line = $1;
$citation = &StripWhiteSpace($2);
if ( $citation !~ m{ \b tclr \b }xi ) {
$jump_destination = lc($citation);
if ( exists($unreported_case_list{$jump_destination}) ) {
$new_line .= "$start_of_line$citation";
$unreported_jl_count++;
}
elsif ( $citation =~ m{ ( \d{1,2} / \d{1,2} / \d{4} | \d{2} ) , .+? ( [a-z]+\d+ (?: / \d+ )? ) }xi ) {
$jump_destination = &NormaliseDate("$1").', '.lc($2);
if ( exists($unreported_case_list{$jump_destination}) ) {
$new_line .= "$start_of_line$citation";
$unreported_jl_count++;
}
else {
$new_line .= "$start_of_line$citation";
}
}
else {
$new_line .= "$start_of_line$citation";
}
}
else {
$new_line .= "$start_of_line$citation";
}
}
$new_line .= $line;
DEBUG('c',"LEAVING DoSomething\n");
return($new_line);
}
#-------------------------------NormaliseDate-----------------------------
# INPUT
# $date
#
# RETURNS
# normalised date
#
# Normalises the input date to dd/dd/dddd format.
#-------------------------------------------------------------------------
sub NormaliseDate {
my($date) = @_;
my($day,
$year,
$month) = (0,0,0);
DEBUG('c',"IN NormaliseDate\n");
if ( $date =~ m{^ ( \d{1,2} ) / ( \d{1,2} ) / ( \d{4} | \d{2} ) $}x ) {
$day = $1;
$month = $2;
$year = $3;
if ( length($day) == 1 ) {
$day = '0'.$day;
}
if ( length($month) == 1 ) {
$month = '0'.$month;
}
if ( length($year) == 2 ) {
$year = '19'.$year;
}
}
DEBUG('c',"LEAVING NormaliseDate\n");
return("$day/$month/$year");
}
#-----------------------------StripWhiteSapce-----------------------------
# INPUT
# $line
#
# RETURNS
# $line
#
# Removes leading and trailing whitespace from the input string.
#-------------------------------------------------------------------------
sub StripWhiteSapce {
my($line) = @_;
DEBUG('c',"IN StripWhiteSapce \n");
$line =~ s{^ \s+ }{}x;
$line =~ s{ \s+ $}{}x;
DEBUG('c',"LEAVING StripWhiteSapce \n");
return($line);
}