in reply to Re^2: perl task...
in thread perl task...

No our course matewrials just cover how to write the code...not to fix the errors...

You are using a text editor to modify the code, aren't you? Do the course materials cover how to use the text editor? Perl comes with a lot of tools that everyone finds quite useful (and often adequate) to debug errors so that you know what needs to be fixed. I see no reason why the course materials should repeat all that information.

Check out the perldebug manual. Better yet, start your script like this:

perl -d name_of_your_script.pl
Then, at the first debugger prompt (DB<1>), type "h" for "help", then try stepping through the program with "n" (or use "s" at a subroutine call to step into that sub). After getting an input from a file, or a regex match or a split, use p $variable to look at what $variable contains, or p join "=  =", @array to see the elements of @array, and so on.

Also, it looks like you were unable to figure out what I was saying in your "perl task3" thread about using while (<DATA>) ... and  __DATA__ in your code. (And maybe you didn't understand what I was saying about the problems being related, and due to your data.) What I meant was:

# my $file = "P1GroupCExercise2_trypsin.txt"; # commented out ... # open(FILE,$file) or die "error: unable to open file $file\n"; # co +mmented out while (<DATA>) # not "<FILE>" { ... } ... __DATA__ >Protein:HEMINF_F3_Complement_N182_S1226717_L118 |Peptide:13|Missed:0|Type:I|Enzyme:trypsin|Seq:R| ...
Now, as for the problems you are still having, is there some chance that you are using a linux, unix or mac system, and the data is coming from a windows system (or from the web)?

In the while loop that reads your data from the file, try these two things:

That will make sure that carriage returns do not get in your way. When I did that on my mac (after fixing the DATA stuff), the script didn't issue any warnings. (But I don't know if it printed the intended output.)