in reply to Merge the difference between two files and save it on the first file. Also update the first file with info in second file.

Nice homework exercise. Forces you to read a file, write a file, and conceptually divides the I/O from the processing by requiring information from both files before writing the output.

There are many ways to do this, but for such a small amount of data (homework exercise unlikely to exceed your system's memory LOL), I'd agree McA on this one -- a hash is definitely the way to go. That does most of the work for you.

  • Comment on Re: Merge the difference between two files and save it on the first file. Also update the first file with info in second file.
  • Download Code

Replies are listed 'Best First'.
Re^2: Merge the difference between two files and save it on the first file. Also update the first file with info in second file.
by Shariq (Initiate) on Oct 11, 2013 at 03:37 UTC
    Actually it is an interesting exercise. What I need this is for remotely configuring my WiFi access points that runs with hostapd. So hostapd has a configuration file called hostapd.conf.

    what I want is to send only the modifications in the conf file over a perl socket. I am able to do that already. But now I need to process the downloaded file and merge into the existing conf file and then reboot the AP.

    I am new to perl so i am stuck for the time being :)