Baratski has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to remove duplicates from an array using the following:
undef %saw; @out = grep(! $saw{$_}++, @array);
When I loop through @out, I find that duplicates are still there.
@array contain paths that have been pushed into it. Each path has an identicle root like so:
Root/abc/file.............
Root/def/ghijk/file.............
Root/file.............
Could the "/" delimiter be messing things up for me? Also, if you'll notice the "............." at the end of each path, these are packed records from a binary file. There is some arbitrary binary data at the end of each record. I've tried unpacking each record into a hex string before pushing them into @array but that didn't seem to help either. Any insight much appreciated. Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: grep confusion
by Zaxo (Archbishop) on Oct 01, 2005 at 19:33 UTC | |
|
Re: grep confusion
by polypompholyx (Chaplain) on Oct 01, 2005 at 19:30 UTC | |
|
Re: grep confusion
by Baratski (Acolyte) on Oct 02, 2005 at 10:17 UTC | |
by Hue-Bond (Priest) on Oct 02, 2005 at 18:51 UTC | |
|
Re: grep confusion
by ambrus (Abbot) on Oct 02, 2005 at 08:12 UTC |