Thread Muster ersetzen (4 answers)
Opened by Gast at 2007-01-08 14:23

esskar
 2007-01-08 14:40
#72943 #72943
User since
2003-08-04
7321 Artikel
ModeratorIn

user image
versuch es mal; habs nicht getestet
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
use strict;
use warnings;

my %lookup = ();
open(F1, "< datei1.txt") or die $!;
while(<F1>) {
$_ =~ s![\r\n]+$!!;
my ($key, $val) = split /-/, $_;
$lookup{$key} = $val;
}
close F1;

my $r = join "|", map keys %lookup;

open(F2, "< datei2.txt") or die $!;
open(F3, "> datei3.txt") or die $!;
while(<F2>) {
s!($r)!$lookup{$1}!ge;
print F3 $_;
}
close F3;
close F3;

View full thread Muster ersetzen