and then loop through the column, print it out and filter off unwanted rows based on the average Coefficient Variance across all dataSXR0X rows (which I will figure out later after I manage to figure out the beginning part).

So my problem here: How to find the column headers matching dataS0XR0X to put those columns into arrays for manipulation?

This code only print out the first value of each $tempratio[x]. and it has error running when I add in the code for the dataSXXRXX columns and intensities.

I am working on large databases and initially I worked with excel but it is too slow and lag my whole computer when performing calculations, so I decided to try PERL instead as I read that it is good for manipulating large datasets. However I am quite new to PERL, just started two months back. So I am not sure if what I am doing is okay. If there are other suggestions, let me know too.

the $columcount variable has not been reset and therefore has the value which which it left the preceding loop, which is probably not what you want. Assuming I am understanding correctly what you are trying to do, $columncount should probably reset to 0 before entering this loop (or, probably even better, to make it a variable lexically scoped to the loop). Another point in this line is that, IMHO, it would be clearer to use the !~ operator rather than negating the =~operator:

But, as I said, your code seems to be far too complicated and I do not understand some of the things that you are doing or why you are doing them. Therefore, I do not wish to go too much into your code, but I will try to write something afresh from your initial explanations if I have time later today (and don't forget about it).

OK, I took some time to look at your problem, but it turns out that there is not enough information on what you really need.

I can only give you some clues. What you probably need to do first is to load your file into a data structure in memory. I decided to use an array of arrays (AoA), although, depending on your exact needs, an array of hashes (AoH), a hash of arrays (HoA) or a hash of hashes (HoH) might turn out to be more practical. But any of these two-dimensional structures can do what you need.

Storing the file into a data structure is done within the while loop, so just 4 lines of code. I made it in several steps to make the process clear, but it could actually be done within just one single code line with this:

Code

push @full_data, [split /\s+/, $_] while (<DATA>);

Next, the for loop is just there to print the data structure and check that everything is OK. This prints out this:

So, this looks OK. If you want a better idea of what the data structure looks like, you can use the Dumper function of the Data::Dumper module that has been loaded at the beginning. You might get a printout similar to this:

From now on, I'll have to make some guesses about what you need, because your description of the requirement is incomplete and the example is at variance with the description. First, replicating your examples:

You would chose between AoA, HoA, AoH and HOH on essentially the same criteria would would use for chosing an array or a hash: basicall, what kind of data access do you need, which type of key do you have, do you need to keep a special order, do you have duplicate keys, etc.