in reply to tweaking of perldoc function (sorting/preserving order)
#!/usr/bin/perl use strict; use warnings; use List::Compare; use Data::Dumper; my @array1 = (1,2,3,4,5); my @array2 = (4,5,6,7,8); #my $lc = List::Compare->new( '-u', \@array1, \@array2); my $lc = List::Compare->new( \@array1, \@array2); my $compare = { 'Union' => [ $lc->get_union ], 'Intersection' => [ $lc->get_intersection ], 'Difference' => [ $lc->get_unique ], 'Sym_diff' => [ $lc->get_symmetric_difference ] }; $Data::Dumper::Indent = 1; print Dumper($compare);
$VAR1 = { 'Intersection' => [ '4', '5' ], 'Sym_diff' => [ '1', '2', '3', '6', '7', '8' ], 'Difference' => [ '1', '2', '3' ], 'Union' => [ '1', '2', '3', '4', '5', '6', '7', '8' ] };
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: tweaking of perldoc function (sorting/preserving order)
by lodin (Hermit) on Jan 18, 2008 at 20:47 UTC |