#!/bin/perl -w use strict; # create the regexp for date, this should be improved my $month = qr/(?:(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\.?)/; my $day = qr/(?:(?:[0-2]?[0-9]|30|31)(?:st|nd|th)?)/; my $year = qr/(?:,?\s*\d+)?/; my $date= qr/($month $day$year)/; # this could probably be improved too! my $number= qr/(\d{2,})/; my %replace; my $i=0; while( ) { chomp; # entitize special characters, those 2 are sufficient here s{&}{&}g; s{<}{<}g; s{(?!<&)$date} {$i++; $replace{$i}="$1"; "&$i;"}eg; # replace the dates s{(?!<&)$number}{$i++; $replace{$i}="$1"; "&$i;"}eg; # replace the numbers s{&(\d+);}{$replace{$1}}g; # replace the &n; print "$_\n"; } __DATA__ On Oct. 21, the Dow Jones rose to 10043 points On May 1st 2001, 12 people were working in France On Nov. 20, I can still tell that 123 < 234