in reply to Re^2: perl quicker than bash?
in thread perl quicker than bash?

Wow! That is so much shorter than what I wrote... lol

I've been reading it through and re-reading... parts of the code I can understand but others are completely new to me (pack, push, my). The bits that I can understand also show how I really could have written that bash script better. :)

I'll keep researching the bits that I don't understand and let the learning begin!

Thank you for your great solution!

Replies are listed 'Best First'.
Re^4: perl quicker than bash?
by Anonymous Monk on Jan 07, 2015 at 21:19 UTC

    my just defines a lexical variable in the current block. push is hopefully easy to understand, pack can get a little complicated - in this case it's turning the first three octets of the IP address into a byte string; so e.g. pack "C3", split /\./, "80.114.108.33" returns the bytes/chars "Prl" (the last octet is ignored because the template is "C3" and not "C4").

    In addition to the general documentation such as perlsyn and perldata (Syntax and Data Types), to understand that code perldsc (Data Structures) will probably be useful; an introduction to the references used to create those data structures is in perlreftut. And a regular expression tutorial is at perlretut.

    See also Modern Perl 2014 (free online edition), Learning Perl, and some of the links on this site: Getting Started with Perl

      Thanks Anonymous Monk, your instructions are well received! Time to grab a coffee and start reading...

      btw: updated my script with an idea from your script. Reduced execution time by 1 second (post has been updated) :)

        Good luck and feel free to ask any questions here!

        (BTW, there are actually several different Anonymous Monks in this thread, but of course it's not easy to tell ;-) When I'm not sure I just assume every anon is different.)