473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to print duplicate words in said text file

i gave input file and output file.can u tell me script.
Attached Files
File Type: txt input.txt (300 Bytes, 338 views)
File Type: txt output.txt (438 Bytes, 343 views)
Dec 16 '13 #1
3 1736
In which programming language?
Dec 16 '13 #2
perl programing language
Dec 19 '13 #3
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.!!

Expand|Select|Wrap|Line Numbers
  1. use warnings;
  2. @values = 0;
  3. $file = "input.txt";
  4. open HNDL, "$file" or die "Unable to open the text file";
  5.  
  6. unlink "output_f.txt";
  7. $out_file = "output_f.txt";
  8. open HNDLR, "+>>$out_file" or die "Unable to generate output file";
  9. while(<HNDL>)
  10.     {
  11.     $line = <HNDL>;
  12.     @values = split(' ', $line);
  13.         if($values = !/support/ || !/name/)
  14.             {
  15.                 print HNDLR " ",$values[1]," ","==>"," ";
  16.             }
  17.             print HNDLR $values[1]," ";
  18.             print HNDLR $values[0],"\n";
  19.             print HNDLR "          ",$line;            
  20.     }
  21.  
  22.  
  23. -------------------output-----
  24.  
  25.  abcd ==> abcd support
  26.           support abcd                                           
  27.  support ==> support wqxz (error)
  28.           wqxz support
  29.  asdf ==> asdf name
  30.           name asdf
  31.  jklm ==> jklm support
  32.           support jklm
  33.  srkl ==> srkl support
  34.           support srkl
  35.  cvbn ==> cvbn name
  36.           name cvbn
  37.  mnopq ==> mnopq name
  38.           name mnopq
  39.  uyti ==> uyti support
  40.           support uyti
  41.  ghjf ==> ghjf support
  42.           support ghjf
  43.  awsz ==> awsz name
  44.           name awsz


-Raj
Aug 15 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Voetleuce en fênsievry | last post by:
Hello everyone. I'm not a JavaScript author myself, but I'm looking for a method to remove duplicate words from a piece of text. This text would presumably be pasted into a text box. I have,...
1
by: Dixie | last post by:
I have a copy of a tab delimited text file that was created from an excel spreadsheet. I want to try to emulate this text file using Access 2000. I don't have access to the spreadsheet, but do...
10
by: Backwards | last post by:
Hello all, I'll start by explaining what my app does so not to confuss you when i ask my question. ☺ I have a VB.Net 2.0 app that starts a process (process.start ...) and passes a prameter...
0
by: pchahar | last post by:
Write a program to process a text file. The program will determine how many unique words there are in the text file that begin with each letter of the alphabet. The text file name will be given as a...
1
hariharanmca
by: hariharanmca | last post by:
How to Fetch Data from Database and print it in a Text File with aligenments using Stored Procedures ( Without any Frontend). Thank you
9
by: rushdi | last post by:
hi, i am trying to convert nos to a special format then print them into a text file. is it possible ? can anyone help me please ?
2
by: woocha | last post by:
I read this thread and realized that it was exactly what I was looking for. The problem is I need it to be done with sentences not words. I have a problems with typing the same thought down twice...
4
by: Nawaf Ali | last post by:
I am trying to do some text statistics, like word frequency, average word length, average sentence length, and average paragraph length, I managed to do the word frequency and the average sentence...
4
by: scharnisto | last post by:
Hi, i need a script, that deletes all the lines between two certain words in a text file. the two words appear several times in the text file. i have a code, that works so far. the problem is,...
4
by: Aplus212 | last post by:
Hi guys, Very new to Python and was hoping you guys could give me some help. I have a book about The Great War, and want to count the times a country appears in the book. So far i have this: ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.