Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2017-12-11 14:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (297 votes). Check out past polls.

    Notices?