my $ref_array1 = @array1;
my $ref_array2 = @array2;
my $str = md5($ref_array1);
my $str2 = md5($ref_array2);
You are doing a digest both times on the count of the items in the arrays, i.e:
print $ref_array1;
print $ref_array2;
outputs:
5
5
Even if you actually took a reference to to these arrays, (my $ref_array1 = \@array1;) your solution would never work, as you would be digesting just a memory code/id for the two named arrays.
The solution here is I suspect, to serialize the arrays & digest the stringified values, e.g:
#!/usr/bin/env perl
use Modern::Perl;
use Data::Dumper;
use Digest::MD5 qw(md5 md5_hex md5_base64);
my @array1 = (
[1,'John','ABXC12132328'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322']
);
my @array2 = (
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322'],
[0,'John','ABXC12132322']
);
my @array3 = @array2;
#print Dumper(\@array1);
my $md5_1 = md5_hex(Dumper(\@array1));
my $md5_2 = md5_hex(Dumper(\@array2));
my $md5_3 = md5_hex(Dumper(\@array3));
say 1,' ',$md5_1;
say 2,' ',$md5_2;
say 3,' ',$md5_3;
This is not a Signature...
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.