|Just another Perl shrine|
Re: deleting lines from fileby AcidHawk (Vicar)
|on Mar 18, 2004 at 12:30 UTC||Need Help??|
Just a few comments (I know it's a little late but hopefully adds more clarity).
Firstly, once you read in a line from oldfile you need to keep it somewhere to check it against $valueToDelete. There are many ways to do this. These include putting each line into an array or even a hash etc.
Secondly, does newfile have anything in it..? if you are appending to newfile your open should look like
or if you are creating newfile from scratch, your open should look like
Also if you are creating the file there will be nothing in it to read so you don't need to do the while loop or the chomp. You can simply do the print if the value you want to print is not like the $valueToDelete. Should you choose to put the lines from oldfile into an array your code would look something like
Another quick note is that when you are printing to newfile you must use your filehandle $ff.
Of all the things I've lost in my life, its my mind I miss the most.