The first thing I notice looking at your code is that your method of populating the hash %sequences would appear to be inconsistent with your routines to parse the contents of the hash. When you read in the file, you count any line without spaces as a header and skip any lines composed entirely of spaces. That would mean that only lines with a mix of spaces and non-spaces would count as values. If you have no such lines, then your hash keys will always have undefined values. Consequently when you visit each key-value pair of the hash in the foreach statement) all of your split routines will be splitting an undefined value.
Now I do note that you expect spaces within the peptide chains portion of non-header lines. But is each and every header row followed by a row with a non-empty value for the peptide chains with at least one space?
Also it is a bit confusing that you are first splitting the non-header line ($value) using a colon ":" and then splitting the same non-header line using a pipe "|". Which is the actual field separator? Or were you intending to split the non-header line into fields using a colon and then split each field into subfields using a pipe? If so you need to move the line splitting each field to inside the foreach loop.
Of course, without any sample data it is hard to what non-header values are like. Perhaps you could provide some sample lines?
A further side note: you would do well to use different names for $value in your inner and outer loops. This makes reading your code confusing. It is also possible that you yourself might sometimes intend the meaning in the outer loop (the entire non-header row terminated by ";") and sometimes the meaning in the inner loop (the subfields created by splitting the row using ":").
Best, beth
In reply to Re: perl task3
by ELISHEVA
in thread perl task3
by huzefa
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |