Load an hash from a text file
From: Web Solving (websolving_at_gmail.com)
Date: 02/28/05
- Next message: Jenda Krynicky: "Re: Understanding split in a while loop"
- Previous message: Ankur Gupta: "Re: Understanding split in a while loop"
- Next in thread: Ankur Gupta: "Re: Load an hash from a text file"
- Reply: Ankur Gupta: "Re: Load an hash from a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 28 Feb 2005 13:48:27 +0100 To: Perl BG <beginners@perl.org>
i rebuilt the scipt without using any hash in this way:
open(INFILE,"lista.txt") || die "Cant read lista.txt. Reason: $!";
while( <INFILE> ){
my ($search, $replace) = split /|/;
open(READIT,"testo.txt") || die "Cant read file.txt. Reason: $!";
open(WRITEIT,">>testo_new.txt") || die "Cant write file_new.txt. Reason: $!";
while (<READIT>) {
$riga = $_;
$riga =~ s/$search/$replace/;
print WRITEIT "$riga\n";
}
close(WRITEIT);
close(READIT);
lista.txt is created like:
Lao Tzu|<\a href="http:\/\/www\.taolaotzu.it>Lao Tzu<\/\a>
Tao|<\a href="http:\/\/www\.confucio.it>Tao<\/\a>
drake|<\a href="http:\/\/www\.dragoni.it>drake<\/\a>
the drake|<\a href="http:\/\/www\.dragoni.it>the drake<\/\a>
typing the command to execute my script a message is show:
Missing right curly or square bracket at search-and-substitute line
17, at the end of line
syntax error at search-and-substitute line 17, at EOF
Execution of search-and-substitute aborted due to compilation errors.
i can't understand what i've to do.
-- WebSolvingJaa: informatica per il web e l'azienda. http://websolvingjaa.altervista.org/
- Next message: Jenda Krynicky: "Re: Understanding split in a while loop"
- Previous message: Ankur Gupta: "Re: Understanding split in a while loop"
- Next in thread: Ankur Gupta: "Re: Load an hash from a text file"
- Reply: Ankur Gupta: "Re: Load an hash from a text file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|