how to move pointer to end of the file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mpatharkar
    New Member
    • Jan 2008
    • 4

    how to move pointer to end of the file

    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.....
  • zippo
    New Member
    • Feb 2008
    • 1

    #2
    Code:
    open(myfile, "input.txt") or die "couldnt open\n";
    open(output, ">output.txt") or die "couldnt open\n";
    $file = <myfile>;
    local $/=undef;
    if($file =~ m/pattern/){
    print output $word;
    
    }
    close(output);
    close(myfile);
    check if this works :)

    Comment

    • KevinADC
      Recognized Expert Specialist
      • Jan 2007
      • 4092

      #3
      Originally posted by mpatharkar
      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.

      Comment

      Working...