|
| Can anyone help me with how to call Array::Compare in a list context?
> #!/usr/bin/perl -w
> use strict;
> use Array::Compare;
> use Data::Dumper;
>
>
>
> my @first = ("1" , "3" , "5" , "7");
> my @second = ("2", "3" , "5" , "6");
>
> my $comp = Array::Compare->new(DefFull => 1); # 0 = Simple 1 = Full
> $comp->compare(\@second, \@first);
>
> # foreach (keys %HASH) {
> # print "$_ => $HASH{$_}\n";
> #}
>
> # print $Array::Compare::diffs;
>
> print($comp);
The above returns Array::Compare=HASH(0x18d7e30). Stepping through
debugger, I can see that it picks up the @diffs at 1 and 3 before
Destroy(). I simplistically tried my @comp = and print @comp;, but
sense that I'm actually trying to get @diffs (within the module).
Overall, my goal is to compare an array that has a mix of text and regex
abstractions with another array of text.
This approach didn't work:
#!/usr/bin/perl -w
use strict;
use Array::Compare;
use Data::Dumper;
my $pattern = '~m/\d/';
my @first = ("1" , "$pattern" , "5" , "6");
my @second = ("2", "3" , "5" , "6");
my $comp = Array::Compare->new(DefFull => 1); # 0 = Simple 1 = Full
$comp->compare(\@second, \@first);
# print $Array::Compare::diffs;
print($comp);
Which returns Array::Compare=HASH(0x18d7e9c), picking up that 0 and 1
are different (as seen in debugger), but not comparing the pattern to 3.
I was hoping to sn a regex comparison into the array 1 eq array 2
with the ~. That didn't work.
I'm probably fishing in the wrong direction, but still don't know enough
perl to help myself.
Thanks,
Chris
|
|