in reply to Remove unique elements from a list of lists
i'm making flattening the array of arrays to an array with duplicate entries, creating a hash with values of the array of arrays as keys, and their count as the hash values.
then i'm iterating over the hash, and if the value equals the length of the array, it appears in every sub-array, so i print it.
#!/usr/local/bin/perl -w use strict; use diagnostics; $|++; my $temp = [ [ '/', '/index.html', '/products/', ], [ '/', '/index.html', ], [ '/', '/index.html', '/products/', ], [ '/', '/index.html', '/test.html', ] ]; my ( $a_ref, $h_ref ); for $a_ref ( @{ $temp } ) { $h_ref->{ $_ }++ for @{ $a_ref }; } for( keys %{ $h_ref } ) { print "$_\n" if $h_ref->{ $_ } == scalar @{ $temp }; }
~Particle ;Þ
|
|---|