in reply to Re^5: Practicing with files
in thread Practicing with files

I don't know how else to say it if what I said don't even make sense to others.

But let me try to give another example

Right now the list of lines in a file reads

Apple

Orange

Grape

SO, if I type grape in once, it says it doesn't exist according to the snippet on the first post.

It only works if I type grape in 3 times to get to the 3rd line, it's all in the same file

I don't want to type the same word 100 times to check all 100 lines before I get to the one I want*******

I want to type in only 1 word, reads every line, if it exist, then remove it and add to the other file.

I really hope this is more understandable.

Replies are listed 'Best First'.
Re^7: Practicing with files
by Jabox (Sexton) on Apr 02, 2014 at 14:00 UTC

    I don't want the if $_ stop only on one line, I want it to loop every line before it goes to else

    I found my solution, had to add this to match it more than once.

    if ($_ =~ m/([$ans]+)/) {