ok - never mind - i seem to have cracked it myself, just had to dereference each of the arrays, check the size, and remove it from the hash if it was sized one or smaller :)
sorry to resurrect this, but need some more advice if anyone can help out - of the two solutions above, I understood rharsh's better so i went with that, however my code now needs to only identify those "colours" that are associated with more than one id. so for my sample input above, i would...
ok, have given this a go with my data - no joy so far :(
this is how i'm populating my hash of arrays:
open (FILE, "result.text")
while( <FILE> ) {
chomp;
## first split ids up from colours
my ($id, $colours) = split('\t', $_, 2);
## now split colours into an array
my @colour_list =...
hi all -
got a bit of a tricky problem, not even sure if there is a way to do it, but i'll happily be proved wrong!!
i have a hash of arrays, generated from a file that looks like this:
id val val val
id val
id val val
and so on. i have had no problem reading this file into a hash of...
thanks steve - but no, that's not quite what i was after, i didn't want the array to "loop round" as it were, so once the final value in the array is reached, the loop should stop. ishnid's suggestion has produced the output i wanted :)
Hi,
I am trying to print an array such that each element is followed by the next one, with a tab character in between, and then a new line, so that:
@array = ("a", "b", "c", "d");
will be displayed as:
a b
b c
c d
so far my code is:
my $i;
my @array = ("a", "b", "c", "d");
my...
Hi,
I am trying to use a hash as a lookup to replace 'placeholders' in a file. I have some raw data that I have read into a hash which looks like this:
id1 val1
id2 val2
id3 val3
so the keys of the hash are the id's. I have another file which looks like this:
enzyme: id1
interacts with...
I have two text files, one of which is a list of names and the other is the "main" file. What I am trying to do is read both files into arrays to that I can identify lines in the "main" file that contain any of the names in my list, and then return those lines from the main file.
For example...
Hi there,
I am writing a small script to search a text database (data_file.txt) that I have already read into a hash of arrays. My command line should look like:
./search.pl -i data_file.txt -k search terms
my problem is that there is usually going to be more than one word following the -k...
Hi,
I have a text database in the following format:
id uid short_name desc org
where all five are tab-delimited. I am trying to read this into a hash of arrays, so that "id" is the key and an array consisting of fields 1 to 4 is the value for each row in my flat file. What I basically need...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.