In addition to the direction given by
the mighty crazy one, I would also point you towards serialisation methods which subsequently allow you to compare complex data structures. The most notable of serialisation modules for Perl would be
Data::Dumper and
Storable - The latter of which can be used to compare data with greater speed than
Data::Dumper with its methods more closely tied to the C-representation of these data objects.
An example piece of comparison code using Storable might look like this:
#!/usr/bin/perl
use Storable qw/freeze/;
use strict;
$Storable::canonical = 1;
my @x = ( '1', '2', '3', '4', '5' );
my @y = ( '1', '2', '3', '4', '5' );
my @z = ( '6', '7', '8', '9', '0' );
print "x = y\n" if (freeze(\@x) eq freeze(\@y)); # True
print "x = z\n" if (freeze(\@x) eq freeze(\@z)); # False
print "x != z\n" if (freeze(\@x) ne freeze(\@z)); # True
Others familiar with this module will recognise the $Storable::canonical = 1 assignment as unnecessary in this example where arrays are being serialised - This assignment will allow Storable to store hashes with their elements sorted by their key, thereby allowing later comparison of the frozen serial structures.
Ooohhh, Rob no beer function well without!
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.