By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,278 Members | 1,518 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,278 IT Pros & Developers. It's quick & easy.

how to move pointer to end of the file

P: 4
I want do program to search a word in the Input file if it is not found then print it to output file.
But the problem is When it search the word in first line of input file and if it is not there then it prints that word to the output file then goes to next line and again search for that word,if it is not there then again it prints it.

I want it to search the total file for that word if it finds it then nothing to do but if it finds then print it to ooutput file.

need a help .....

mahesh.....
Jan 29 '08 #1
Share this Question
Share on Google+
2 Replies


P: 1
Expand|Select|Wrap|Line Numbers
  1. open(myfile, "input.txt") or die "couldnt open\n";
  2. open(output, ">output.txt") or die "couldnt open\n";
  3. $file = <myfile>;
  4. local $/=undef;
  5. if($file =~ m/pattern/){
  6. print output $word;
  7.  
  8. }
  9. close(output);
  10. close(myfile);
  11.  
check if this works :)
Feb 13 '08 #2

KevinADC
Expert 2.5K+
P: 4,059
But the problem is When it search the word in first line of input file and if it is not there then it prints that word to the output file then goes to next line and again search for that word,if it is not there then again it prints it.

I want it to search the total file for that word if it finds it then nothing to do but if it finds then print it to ooutput file.

need a help .....

mahesh.....
If you need help with your code you have to post your code. We can not help with code we can not see. If you just wanted someone to write the code for you, well someone did that already, maybe it even works.
Feb 13 '08 #3

Post your reply

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