Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: output using map

by Marshall (Canon)
on Mar 07, 2020 at 01:35 UTC ( [id://11113926]=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11113926]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (7)
As of 2024-04-24 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found