Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Fast Way to Return Unique Array of Array

by TedPride (Priest)
on Sep 05, 2005 at 06:21 UTC ( [id://489151]=note: print w/replies, xml ) Need Help??


in reply to Fast Way to Return Unique Array of Array

Just set $delim to whatever character or sequence of characters is not going to be found inside any of your nested array fields. I used tabs.
use strict; use warnings; use Data::Dumper; my @AoA = (['a','b','c'], ['a','b','c'], ['a','b','d'], ['a','b','d']); my (%h, @uAoA); for (@AoA) { push @uAoA, $_ if !$h{join $;, @$_}++; } print Dumper \@uAoA;
EDIT: Edited code to use $;, as per suggestion.

Replies are listed 'Best First'.
Re^2: Fast Way to Return Unique Array of Array
by Anonymous Monk on Sep 05, 2005 at 07:00 UTC
    nice solution, but better to use $; instead of $delim IMHO.... see perlvar manpage.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://489151]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (2)
As of 2024-04-25 20:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found