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.
In reply to Re: Copying files from one file to another file
by harishnv
in thread Copying files from one file to another file
by harishnv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |