RegExp won't match :(
Hello all 
I'm puzzling around with a script which can "translate" internet pages using a dictionary by using RegExp substituting. The only problem is that I don't want links or sources of images to be translated because then they would not point to correct and valid pages.
I've found a way to avoid this, but it doesn't work
(So much for my idea :P)
Code:
open WORDS, "../dict.txt"
or die "Couldn't open txt file :(";
for $word (@wordsin = <WORDS>)
{
my $temp;
my @temp = split/&/, $word;
$words{$temp[0]} = $temp[1];
}
close WORDS;
my $key;
my $finishedcont = get($url);
foreach $key (keys %words)
{
#For each word, substitute every occurence with the translated value surrounded by the string "123"
$finishedcont =~ s{$key}{123$words{$key}123}gis;
#Now change every occurence of the current translated word surrounded by 123 inside =" " (Typical links or image sources) back to the original
$finishedcont =~ s{="(.*)?(123$words{$key}123)(.*)?"}{="$1$key$3"}gis;
#Strip of the surrounding 123's from the untouched translations
$finishedcont =~ s{123$words{$key}123}{$words{$key}}gis;
}
In the dictionary, the words are written as such:
original_word&translated_word
I then assign this to a hash where the key is the original word, and the value is the translated one.
My problem here is that the middle substitute doesn't work... Nothing is translated back, even though it is a link with the correct formatting... 
Anyone know where I've screwed up? 
Thanks in advance
Johnoo
Relax, everything is going perfectly out of control
The great thing about a computer notebook is that no matter how much you stuff into it, it doesn't get bigger or heavier.
Bill Gates (1955 - ), Business @ The Speed of Thought
Bookmarks