in reply to Re^2: output using map
in thread output using map

I think you are correct about the intent of unpack. However this is a bad way to do it, if that is the intent. There might also be some issue related to UTF-8 filenames? But again this is not the "right way".

I chomped the input lines and added back in a platform specific line ending in the print because in general, I don't store line endings in data structures because I strive for multi-platform code.

Yes, foreach (keys %first_file) {} could be: foreach (sort keys %first_file) {}

Replies are listed 'Best First'.
Re^4: output using map
by Anonymous Monk on Mar 07, 2020 at 06:57 UTC

    The sorting of keys (or, lines) does not help as the output would be out of sync from the order in a file. OP's code (after rewinding the file handle) would have printed the difference in lines in the same order as the lines appear in a file.

    Use of hash in OP was a handy way to keep track of lines seen. I think to keep the order of lines printed was the reason that coding_new opened the same files twice. I personally would have generated the hash with line as key & $. as value. To print, then I would have sorted on the hash value. I personally would have used Algorithm::Diff.