Hi all, i'm a real perl newbie. i've a question for you all. i've to
perform a "search and replace" on a text file, and i wrote this:
open(READIT,"file.txt") || die "Cant read file.txt. Reason: $!";
open(WRITEIT,">>file_new.txt") || die "Cant write file_new.txt. Reason: $!";
while (<READIT>) {

  if ($riga =~ /una pallina/) {
     $riga =~ s/una pallina/<a href="http:/\/\www.pollino.it>una pallina</a>/;
  }
  elsif ($_ =~ /pallina/) {
     $riga =~ s/pallina/<\a href="http:\/\/www\.pollino.it>pallina<\/\a>/;
  }

  if ($riga =~ /un cobra/) {
     $riga =~ s/un cobra/<a href="http:/\/\www.serpentoni.it>un cobra</a>/;
  }
  elsif ($_ =~ /cobra/) {
     $riga =~ s/cobra/<\a href="http:\/\/www\.serpentoni.it>cobra<\/\a>/;
  }

  print WRITEIT "$riga\n";

}
close(WRITEIT);
close(READIT);

i need to load the corrispondence "world to be seek"=>"replaced word"
from another text file, like this:
word|<\a href="http:\/\/www\.word.it>word<\/\a>
the word|<\a href="http:\/\/www\.word.it>the word<\/\a>
a word|<\a href="http:\/\/www\.word.it>a word<\/\a>
word2|<\a href="http:\/\/www\.word2.it>word2<\/\a>
the word2|<\a href="http:\/\/www\.word2.it>the word2<\/\a>
a word2|<\a href="http:\/\/www\.word2.it>a word2<\/\a>
eccetera.....

so i think i can use an hash, but i can't
understand how i can load the txt file in an hash, i tried to search
the answer of my question in several tutorials but i can't find
anything about it. can u help me?
-- 
WebSolvingJaa: informatica per il web e l'azienda.
http://websolvingjaa.altervista.org/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to