Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

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.

Cheers,

JohnGG

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1032974]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (11)
As of 2016-06-30 15:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (396 votes). Check out past polls.