Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: quick way to add value of a hash with same x, y, z?

by QM (Parson)
on Aug 10, 2017 at 10:08 UTC ( #1197145=note: print w/replies, xml ) Need Help??


in reply to quick way to add value of a hash with same x, y, z?

Quick comments: Use a hash on the first file, such as:
$hash{"$x,$y,$z"}{no} = $no; $hash{"$x,$y,$z"}{pressure} = $pressure;

Then with the coords from the second file, search in the hash for matching coords.

Problem: The coords have a lot of decimal places. These should be normalized before creating the hash entries, and before searching the hash keys. Decide how many significant digits are more than enough, and use sprintf with a fixed decimal ("f") descriptor.

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2021-04-10 22:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?