Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re^2: Is Using Threads Slower Than Not Using Threads?

by Dru (Hermit)
on Nov 01, 2010 at 14:47 UTC ( #868771=note: print w/replies, xml ) Need Help??

in reply to Re: Is Using Threads Slower Than Not Using Threads?
in thread Is Using Threads Slower Than Not Using Threads?

Thank you GrandFather. What do you mean by normalizing the IP numbers?


Perl, the Leatherman of Programming languages. - qazwart

Replies are listed 'Best First'.
Re^3: Is Using Threads Slower Than Not Using Threads?
by GrandFather (Sage) on Nov 01, 2010 at 20:39 UTC

    For the hash lookup to work the key string must exactly match. IP numbers may optionally have leading 0 digits to for a three digit number but the strings '' and '' are not eq so you should normalise the IP number to one version or the other - always three digit numbers or always remove leading 0 digits.

    True laziness is hard work
Re^3: Is Using Threads Slower Than Not Using Threads?
by BrowserUk (Pope) on Nov 01, 2010 at 22:08 UTC

    The easiest way to normalise IPs is to pack them to integers:

    $hash{ pack 'C4', split '.', $ip } = 1;

      <beancounter>That works "only" for IPv4 addresses.</beancounter>.

      We are running out of IPv4 addresses, and the only alternative to massive (ab)use of NAT is to switch to IPv6 really soon now(TM). In that light, new applications should be able to handle IPv6 addresses now.

      Of course, for a logfile with 100% IPv4 addresses, adding IPv6 support is nonsense. But, if that logfile comes from a device that will soon have to work with IPv6 addresses, the script should be able to handle that.


      Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

        Agreed. But since all the regexes in threads dealt only IPv4; it was worth mentioning.

        That said, with currently less 0.5% of traffic using IPv6, and the whole raft of other issues from hardware & software incompatibilities; to wide-open, untested security; to privacy issues, I think we are destined to see all but the largest of organisations ignoring the existence of IPv6 for the foreseeable future.

        There's also a school of thought that rather than viewing the use of NAT as abuse, that simply extending its use to the highest level (backbone) ISPs, and having them hand back huge rafts of their currently allocations, would solve the problems far more simply and cheaply than moving to IPv6.

        With only one level NAT you potentially get 16 quadrillion addresses. Sure, it's not as many as IPv6's 3.4x1038, but that's just ludicrous overkill.

        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://868771]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (5)
As of 2018-06-20 15:45 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (116 votes). Check out past polls.