Hi Monks.
So now I have 1 array, and 1 arraylist.
@tocheck : Apple Corn Pie Fish %checkfrom: Meat => Fish Apple Pork Bacon Fruit => Apple Pie Orange Beef
Well that's the gist of it at least. I'm trying to remove the values that are in the array @tocheck from the hash %checkfrom. So the end result is something like this:
Meat=> Pork Bacon Fruit => Orange Beef
Well but there are several thousand keys in the %checkfrom, and probably about the same number of elements in @tocheck. Is there anything faster than checking like this? Also how can I remove the value from the value key pair? I know delete $checkfrom{$_} deletes the entire key/value pair.
foreach $checking(@tocheck){ for (keys %checkfrom){ if ($checkfrom{$_} eq $checking){ #does }
Thanks Monks!
Update:
Well, since this example isnt working, I shall post my full code and files up here.Activpospf.txt PF01486 PF00319 PF04947 PFACTest.txt PF01486 : C12345 C23456 PF00319 : C15234 PF12345 : C00001 C12345 PF98765 : C00000
These are just small files so I can test them out. The actual files are much bigger.
#!/usr/bin/perl use Modern::Perl; use File::Slurp qw/read_file write_file/; my $pfaminput ='Activpospf.txt'; my $seedinput ='PFACtest.txt'; #open POSITIVEOUT, ">", 'ActivPosdata.txt'; #open NEGATIVEOUT, ">", 'ActivNeg.txt'; my %seedin =map{chomp; /(.+)\s+\:\s+(.+)/;$1=>$2;} read_file $seedinp +ut; my $pfam; my @tocheck; my @negative; for $pfam(read_file $pfaminput){ chomp ($pfam); if (defined $seedin{$pfam}) { my @splitter =split(/ /, $seedin{$pfam}); push (@tocheck, @splitter); delete $seedin{$pfam};}}
What I intend to get is to remove the entire lines from PFACtest which have the PF values that are in Activpospf.txt, and also to use the numbers that are within those lines that are removed, and remove them from the rest of the file. i.e. this:
PF12345 : C00001 PF98765 : C00000
Thanks!
In reply to Removal of values in array from array list by jemswira
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |