i gave input file and output file.can u tell me script.
how to print duplicate words in said text file
Collapse
X
-
Tags: None
-
-
-
Hi Hari,
here's the script for following output. There is a small error in the output.. couldn't fix it... :(
it could be great if you can explain the logic behind the generation of output.!!
Code:use warnings; @values = 0; $file = "input.txt"; open HNDL, "$file" or die "Unable to open the text file"; unlink "output_f.txt"; $out_file = "output_f.txt"; open HNDLR, "+>>$out_file" or die "Unable to generate output file"; while(<HNDL>) { $line = <HNDL>; @values = split(' ', $line); if($values = !/support/ || !/name/) { print HNDLR " ",$values[1]," ","==>"," "; } print HNDLR $values[1]," "; print HNDLR $values[0],"\n"; print HNDLR " ",$line; } -------------------output----- abcd ==> abcd support support abcd [B] support ==> support wqxz (error) wqxz support [/B] asdf ==> asdf name name asdf jklm ==> jklm support support jklm srkl ==> srkl support support srkl cvbn ==> cvbn name name cvbn mnopq ==> mnopq name name mnopq uyti ==> uyti support support uyti ghjf ==> ghjf support support ghjf awsz ==> awsz name name awsz
-RajLast edited by Rabbit; Aug 15 '14, 10:39 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.Comment
Comment