in reply to Copying files from one file to another file
my @arr= nv.txt; my (%hash, $key, $val); foreach (@arr) { $pre1="\$hash{$key}"; #previous key of the loop $pre2=$val; #previous value of the loop ($key, $val) = split (/:/,$_,2); if($pre1 eq "\$hash{$key}") #if previous and current key same { $hash{$key}= $pre . '\n' . $val; #concatenate } $hash{key}=$val; print "\$hash{$key}={$vaal}\n"; }
code> output test/right/case1:12 : //comment :344: //comment test/wrong/case3:123: //commentinput file nv.txt has files in the form of a array like this, test/right/case1:12: //comment test/right/case1:344: //comment test/wrong/case3:123: //comment
If the path address is same, then values should be saved in one key(path address) else different key. I think I'm not able to concatenate now or if there should be any other solution or modification, help me.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Copying files from one file to another file
by poj (Abbot) on Feb 20, 2018 at 11:00 UTC | |
by harishnv (Sexton) on Feb 20, 2018 at 11:03 UTC | |
by poj (Abbot) on Feb 20, 2018 at 11:09 UTC | |
by harishnv (Sexton) on Feb 20, 2018 at 11:20 UTC | |
by harishnv (Sexton) on Feb 21, 2018 at 04:48 UTC |