in reply to removing duplicates from do script

Because in the first case you are still inside the loop when you print the array @out, and in the second case you reassign to the array @arr1 each time through the loop.

Update: try this (untested):

my @wanted; for my $line ( @lines ) { my @fields = split /,/, $line; if ( $fields[2] eq '1' || $fields[2] eq '0' ) { push @wanted, $fields[4]; } } @wanted = uniq @wanted; print "$_\n" for @wanted;

Hope this helps!


The way forward always starts with a minimal test.

Replies are listed 'Best First'.
Re^2: removing duplicates from do script
by bigip2000 (Initiate) on Mar 01, 2017 at 16:33 UTC

    That's it!!!! worked like a real charm. I tried a similar method but didn't eliminate the "do" from the script, that is why it didn't work. THANK YOU!!!