I have a hash with keys and values stored in it. The keys are floating point numbers(i.e 0.423.0.523 etc).
This tells me enough to conclude that you're using the wrong data structure.
- Floating point numbers are somewhat elusive, you never get exact values for floating points. So the string representation of the numbers, which is slightly more stable, is still rather unreliable.
- What if you have a conflict? What if 2 "URL"s have the same key value? What if they're slightly different? You may have one hash entry, or you may have 2.
What I think you want is a data structure containing pairs (AKA "tuples") of (numeric value, url).
i want only the values greater than 0.4
Even more evidence you don't really want Perl hashes.
IMO this is more suitable for what you're after:
@data = (
[ 0.423, 'http://google.com/' ],
[ 0.523, 'http://bing.com/' ],
);
You can use
grep to extract the tuples that match your requirements.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.