in reply to Re^3: Find Replace text with list
in thread Find Replace text with list
#!/usr/bin/perl use strict; use warnings; my $filename = 'data'; my $sfilename = 'source.txt'; my $tfilename = 'target.txt'; open(DFILE, $filename) or die "Could not read from $filename, program +halting."; open(SFILE, $sfilename) or die "Could not read from $filename, program + halting."; open(TFILE, "> $tfilename") || die("Cannot Open File"); while(my $SBR=<DFILE>) { my @fields = split(':', $SBR); my $rRegex = qr/$fields[0]/; my $Regexr = qr/$fields[1]/; for my $s (qw(/hang /hung /hing /heng)) { #here I need read it + as a source file, compare to data file if ($s =~ $rRegex){ print TFILE "$fields[1] "; # then write it to target file } } } close DFILE; close SFILE; close TFILE;
|
|---|