in reply to Re^2: Howto Avoid Memory Problem in List::MoreUtils
in thread Howto Avoid Memory Problem in List::MoreUtils

Hi salva,
Thanks so much for your reply. Just a minor question. What's the meaning of this line:
$array[$j] = $last = $e;
Why not simply:
$array[$j] = $e;

Replies are listed 'Best First'.
Re^4: Howto Avoid Memory Problem in List::MoreUtils
by ikegami (Patriarch) on May 09, 2006 at 06:03 UTC
    $last is used to remove dups. $last needs to be set to the $e of this pass to compare it to the $e of the next pass. I suppose you could get rid of $last and do
    @array = sort @array; my $j = -1; for my $e (@array) { if ($j < 0 || $array[$j] ne $e) { $array[++$j] = $e; } } $#array = $j;