I have a script that runs a do statement as follows:
my @list = (@lines); foreach (@lines) { my @fields = split /,/; if ( $fields[2] eq '1' || $fields[2] eq '0' ) { @arr1 = do {"@fields[4]\n"}; my @out = uniq @arr1; print "this is @out"; } }
Even though I am using use List::MoreUtils qw(uniq); I never get the duplicates removed. What I get from the output of the @arr1 is
this is out XY-CAR-SHOP1_RADIATOR-PARTS this is out XY-CAR-SHOP1_RADIATOR-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS this is out QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS
Why don't the duplicates get removed? It should look like this: XY-CAR-SHOP1_RADIATOR-PARTS QZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS I have tried also the following:
my @list = (@lines); foreach (@lines) { my @fields = split /,/; if ( $fields[2] eq '1' || $fields[2] eq '0' ) { @arr1 = do {"@fields[4]\n"}; } } my @out = uniq @arr1; print "this is @out";
But that only causes one line to print out, the last one:
and missesQZ-CAR-STORE2-PRACTICAL_SNOWTIRE-02-X3-PARTS
can anyone help?XY-CAR-SHOP1_RADIATOR-PARTS
In reply to removing duplicates from do script by bigip2000
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |