in reply to Comparing files and and elements of arrays

What is the exact code you have been using? It's hard to help you fix something we can't see ...

As for basic issues, you cannot edit a file directly from Perl. You (generally) have to:

  1. Open a filehandle to read the file
  2. Read the file into some data structure
  3. Close the read-only filehandle
  4. Edit the data structure
  5. Open a filehandle to overwrite the file
  6. Write the data structure to the file
  7. Close the write-only filehandle

I suspect you're missing the first close and second open. That's a common mistake among newbies. To match the above 7 steps to your needs, you'll need to repeat steps 1-3 for both files.

------
We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

  • Comment on Re: Comparing files and and elements of arrays