Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: removing duplicates from do script

by thanos1983 (Parson)
on Feb 28, 2017 at 17:14 UTC ( [id://1183172]=note: print w/replies, xml ) Need Help??


in reply to removing duplicates from do script

Hello bigip2000,

Try something like this:

I did not test your code as it is incomplete.

my @list = (@lines); $array_element = 0; foreach my $line (@lines) { my @fields = split /,/ $line; if ( $fields[2] eq '1' || $fields[2] eq '0' ) { #@arr1 = do {"@fields[4]\n"}; splice @arr1, arr1[$array_element], 1; } $array_element++; } my @out = uniq @arr1; print "this is @out";

Read more about it here: (How do I completely remove an element from an array?)

Update: I got confused I thought you want to remove the whole line. The correct solution is what 1nickt proposed.

Seeking for Perl wisdom...on the process of learning...not there...yet!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 16:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found