Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Check if sort has changed order

by johngg (Abbot)
on May 10, 2013 at 15:47 UTC ( #1032974=note: print w/replies, xml ) Need Help??

in reply to Check if sort has changed order

Use Digest::MD5 to see if something has changed. The md5_hex() function will concatenate its arguments then operate on the concatenated string.

$ perl -Mstrict -Mwarnings -MDigest::MD5=md5_hex -E ' my @arr1 = qw{ tiger bear shark lion }; say md5_hex( @arr1 ); say md5_hex( sort @arr1 );' 4c15f2e87b25ac112649edfd426d5082 27f304e4e99072211806f923bbb39705 $ perl -Mstrict -Mwarnings -MDigest::MD5=md5_hex -E ' > my @arr1 = qw{ antelope cow deer sheep }; > say md5_hex( @arr1 ); > say md5_hex( sort @arr1 );' 1f0210f9b5d6dababea92da7018905da 1f0210f9b5d6dababea92da7018905da $

I hope this is of interest.



Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032974]
[Corion]: Nicholas Clark++ # read for a multichar block-delimiter by scanning for the last char, and only then check whether the whole delimiter was read.
[Corion]: At least if you're appending the data read to a larger buffer, this means you avoid the situation of "a delimiter was found but the other half has not been read yet"
choroba misses the context
[Corion]: choroba: Optimizing how Perl reads source code on startup (and then processes it line-by-line)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2016-12-06 14:59 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (107 votes). Check out past polls.