#!/usr/bin/perl # Calculates the age of a paper citation. # Author: Ian Hickman use strict; use Time::Local; my %months=( "Jan", 0, "Feb", 1, "Mar", 2, "Apr", 3, "May", 4, "Jun", 5, "Jul", 6, "Aug", 7, "Sep", 8, "Oct", 9, "Nov", 10, "Dec", 11 ); my (%table, %subtimes ); my ($day, $month, $monthtext, $year); my ($paper, @field); my ($hittime, $subtime, $diff); my $line=0; print STDERR "opening paper dates\n"; openpapers(); print STDERR "doing the rest\n"; while( ){ @field=split; # get the date the paper was first submitted (nearest day) if( exists($subtimes{$field[0]}) ){ if( exists($subtimes{$field[1]}) ){ print"$field[0] $subtimes{$field[0]} $field[1] $subtimes{$field[1]}\n"; } else { print STDERR "target paper $field[1] not in d_firstsubmit\n"; } } else { print STDERR "paper $field[0] not in d_firstsubmit\n"; } } my $time; foreach $time ( keys ( %table ) ){ print"$time\t$table{$time}\n"; } sub openpapers{ my ( $time, $day, $month, $year ); open( PAPERLIST, "../d_firstsubmit" ) || die"Cant open paperlist: $!"; # loop through all the papers while( defined( $_ = )){ # loop through list of papers getting date and paperid my @field; @field=split; $_=$field[0]; ($year, $month, $day)=/(....)(..)(..)/; if( $month>0 ){ $time=timelocal( 0, 0, 0, $day, $month-1, $year ); if( !(exists ($subtimes{$field[2]})) ){ $time/=(24*3600); if( int($time) ne $time ){ if( int($time) > ($time-0.5) ){ $time=int($time); } elsif( int($time) <= ($time-0.5) ){ $time=int($time)+1; } } $subtimes{$field[2]}=$time; } else { print"clash\n"; } } } close( PAPERLIST ) || die"Cant close paper list: $!"; }