Just taking a guess at what you are doing, I created a file of 1500 random IP-like addresses

$ perl -E ' say join q{.}, map { int rand 256 } 1 .. 4 for 1 .. 1500;' > spw1112250.dat $

I then put a script together to read the file and construct a hash keyed on the first three octets then look up another octet to see if it occurred in the data file. I timed the process in the script which took milliseconds rather than seconds on a fairly old laptop.

use strict; use warnings; use 5.014; use Time::HiRes qw{ gettimeofday tv_interval }; my $startTV = [ gettimeofday() ]; my $inFile = q{spw1112250.dat}; open my $inFH, q{<}, $inFile or die qq{open: < $inFile: $!\n}; my @lines = <$inFH>; close $inFH or die qq{close: < $inFile: $!\n}; s{\.\d+$}{} for @lines; my %lookupIPs; @lookupIPs{ @lines } = ( 1 ) x @lines; my $lookFor = q{17.23.213}; say qq{$lookFor }, $lookupIPs{ $lookFor } ? q{} : q{not }, qq{found in $inFile}; say qq{Process took @{ [ tv_interval( $startTV, [ gettimeofday() ] ) ] + } seconds};

The output.

17.23.213 not found in spw1112250.dat Process took 0.002678 seconds

Of course, your integer comparison may be more complex than this simple lookup. Perhaps you could show us exactly what your comparison does.

Cheers,

JohnGG


In reply to Re: perl quicker than bash? by johngg
in thread perl quicker than bash? by TiffanyButterfly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.