in reply to Re^3: Replacement of data in a column of a file using Hashes created from another file
in thread Replacement of data in a column of a file using Hashes created from another file
Hi, Try this one
use strict; use warnings; my ($a, $b, $c) = @ARGV; open(FILE, "$a"); my $text=do {local $/; <FILE>}; close FILE; my %mymatch = $text =~ m/^\s*(.*?)\s*\=\s*(.*?)\s*$/igm; open(FILE, "$b"); my $maintext=do {local $/; <FILE>}; close FILE; foreach my $myfnd (sort {length($b) <=> length($a)} keys %mymatch) { $maintext =~ s/\Q$myfnd\E/$mymatch{$myfnd}/ig; } open(FILE,">$c"); print FILE $maintext; close FILE;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Replacement of data in a column of a file using Hashes created from another file
by Anonymous Monk on Oct 30, 2012 at 23:27 UTC | |
by space_monk (Chaplain) on Oct 31, 2012 at 02:51 UTC | |
|
Re^5: Replacement of data in a column of a file using Hashes created from another file
by rohitmonk (Initiate) on Oct 31, 2012 at 05:49 UTC |