Dear Masters,
Given an AoA and a array reference, I want to check
if the array ref is a memeber of the AoA.
How come my code below doesn't do the job correctly?
And is there any efficient way to do this?
In particular
I need to check against AoA of size around 2000 entries.
use strict;
use Data::Dumper;
use List::Compare;
my @AoA = (
[ 'beethoven', 'berlioz', 'strauss' ],
[ 'wagner', 'mozart', 'brahms' ],
[ 'sibelius', 'elgar', 'dvorak' ]
);
# Should return 1 (True)
my $test = [ 'wagner', 'mozart', 'brahms' ];
# Should return 0 (False)
my $test2 = [ 'faure', 'debussy', 'stravinksy' ];
print check_if_inst_occur_already(\@AoA,$test),"\n";
print check_if_inst_occur_already(\@AoA,$test2),"\n";
sub check_if_inst_occur_already {
my ( $store, $inst_set ) = @_;
INST_ALREADY:
foreach my $ins_already ( @{$store} ) {
my $lc = List::Compare->new( $ins_already, $inst_set );
my $eq = $lc->is_LeqvlntR;
print "EQ : $eq\n";
if ( $eq == 0 ) {
return 0;
}
else {
return 1;
last INST_ALREADY;
}
}
}
---
neversaint and everlastingly indebted.......
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.