in reply to Switching the Order of Lines
You can use reverse on an array or list too, and consequently get the lines to be processed in reverse order:
foreach my $protein ( reverse @protein ) { ...
Or you could use File::ReadBackwards, and do something more like this:
while( defined( my $protein = $backward_fh->readline ) ) { if( ....
I would probably prefer the latter, because it totally removes the need to slurp the entire file all at once. Maybe that's not an issue for you, but if proteins.txt has the potential of growing really large, line-by-line processing is advantageous.
(Be sure to read the documentation on File::ReadBackwards; I didn't demonstrate instantiating the iterator because it's pretty clear in the POD)
Dave
|
|---|