perl script to find, write, repeat...


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting perl script to find, write, repeat...
# 1  
Old 07-03-2012
perl script to find, write, repeat...

I am a novice writing perl scripts so I'd appreciate any help you guys can offer.
I have a list of 100 words in a file (words.txt) and I need to find them in a second file (data.txt). Whenever one of these words is found I need to write that line to a third file (out.txt) and then continue searching for more matches. I've tried using grep, and it works fine for just doing one word at a time, but it is completely unworkable once I try to do all of them. Anyway, I thought a perl script might be the way to go but I'm completely stumped as to where to start.
Thanks!
# 2  
Old 07-04-2012
Why is grep unworkable? Did you try:
Code:
grep -f words.txt data.txt > out.txt

?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl to adjust coordinates based on repeat string

In the file below I am trying to count the given repeats of A,T,C,G in each string of letters. Each sequence is below the > and it is possible for a string of repeats to wrap from the line above. For example, in the first line the last letter is a T and the next lines has 3 more. I think the below... (10 Replies)
Discussion started by: cmccabe
10 Replies

2. Shell Programming and Scripting

How to write Perl Script to Get MQ Queue Depth?

Hi , I got the following script from internet to display queue depth using Perl Script. However, when I execute it , im getting following error. Can anyone shed light on what is going wrong? #!/usr/bin/perl ## 07/23/01 ## Depth Inquiry sample program. ## Arguments: ## Connects to... (11 Replies)
Discussion started by: srkmish
11 Replies

3. Shell Programming and Scripting

Perl script to create/write into spreadsheet

Hi, I need help in debug following script. can somebody help....!!! #!/usr/bin/perl -w use strict; use Spreadsheet::WriteExcel; # Create a new workbook called simple.xls and add a worksheet. my $workbook = Spreadsheet::WriteExcel->new('simple.xls'); my $worksheet =... (1 Reply)
Discussion started by: chettyravi
1 Replies

4. Shell Programming and Scripting

Need a UNIX/perl script to read and write the data

Hi, I have on Designdocument in that information is stored with in tabular format.I need Perl/unix script to read and write the data using perl script? Regards, Ravi (4 Replies)
Discussion started by: toravi.pentaho
4 Replies

5. Shell Programming and Scripting

Need a perl script to read and write the data

Hi, I have on Designdocument in that information is stored with in tabular format.I need Perlscript to read and write the datausing perl script? Regards, Ravi (0 Replies)
Discussion started by: toravi.pentaho
0 Replies

6. Shell Programming and Scripting

How to write a update query in perl script?

can any one suggest me on how to write a update query in perl script for Oracle database and also tell me abt how we can write a code for sending mails with report as attachment to appropriate persons? (1 Reply)
Discussion started by: Ramesh V Kumar
1 Replies

7. Homework & Coursework Questions

Shell script calling Perl function, sort and find data, write to new files

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I must write a shell script that calls two external Perl functions--one of which sorts the data in a file, and... (6 Replies)
Discussion started by: kowit010
6 Replies

8. UNIX for Dummies Questions & Answers

Should I write a PERL Script or Shell Script?

Hello, I have done some BASIC shell scripting/PERL scripting before so I am familiar with the languages. I am not really sure which one would lend itself better to the application I have to write. I am required to scan the message logs for possible break in attempts. If I use shell scripting... (2 Replies)
Discussion started by: mojoman
2 Replies

9. Shell Programming and Scripting

Need help to write a Perl script

Hello friends, I am having a awk script which does my goal , but I want to learn perl , after learning the basics in perl now I am trying to convert my nawk script to perl . Please help me to do some task in perl that I ve already did in nawk. Like I am facing some problem in... (10 Replies)
Discussion started by: user_prady
10 Replies

10. Shell Programming and Scripting

Please help me to write a Script to find out whether website is up!!!!!!!

Hello friends I have to write a script in linux to find out the website is up or down..... Please help me in this thank you Jay (1 Reply)
Discussion started by: jai143
1 Replies
Login or Register to Ask a Question