biologistatsea has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a script for performing comparisons among files - but the total number of file inputs varies from case to case.
I would like to use the List::Compare methods for performing these comparisons. However I don't know how to pass an unknown number of array references to build the List::compare object.
For example, after reading the inputs my data might be stored in %HASH : $HASH{$filename}{$groupname}=group members. I can then loop through the hash and put the groupnames for each file in an array. But how do I collect these arrays and pass references to them to List::Compare?
Here's an example of some minimal code of the sort of thing I've tried to get the array references into the object. Any help or solutions would be very much appreciated!
use warnings; use strict; use List::Compare; my @S1 = ( 'G1', 'G3', 'G5' ); my @S2 = ( 'G1', 'G3', 'G5', 'G7', 'G12' ); my @S3 = ( 'G1', 'G5' ); my @A = ('\@S1', '\@S2', '\@S3'); my $var = join ',' , @A; my $lc = List::Compare->new('--unsorted', "$var"); my @intersection = $lc->get_intersection; print "intesection is @intersection\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Building List::Compare objects for unknown numbers of objects
by hippo (Archbishop) on Nov 21, 2018 at 11:38 UTC | |
by biologistatsea (Acolyte) on Nov 21, 2018 at 12:08 UTC | |
by hippo (Archbishop) on Nov 21, 2018 at 14:13 UTC |