Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^4: Replacement of data in a column of a file using Hashes created from another file

by perl_walker (Novice)
on Oct 30, 2012 at 14:49 UTC ( #1001518=note: print w/ replies, xml ) Need Help??


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;


Comment on Re^4: Replacement of data in a column of a file using Hashes created from another file
Download Code
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
    Why don't you do error checking?

      He's obviously from the Klingon school of programming; error checking is for the weak! ;-)

      More seriously programs on here are to demonstrate general principles and outline solutions to the problem raised, not full solutions with complete error checking, unless error checking is the specific issue raised.

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

    Thanks a ton perl walker, keep walking ;) <\p>

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1001518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-09-02 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (19 votes), past polls