in reply to matching &printing S variable of an array

Like CountZero already pointed out:
chomp(); # remove the newline from $_; $peptide = $_; # Current peptide (line) being checked push(@peptides, $peptide); # Adds each peptide to an array (note the s +ingular/plural)
The thing is, if you want the last element of an array, you need to do: $peptide = $peptides[$#peptides]

Alternatively, you can write both assignments in a single line:

push(@peptides, $peptide = $_);

Replies are listed 'Best First'.
Re^2: matching &printing S variable of an array
by Bijgom (Initiate) on Feb 24, 2015 at 08:49 UTC
    Cheers guys! The solution consisting in initializing $peptide while populating my array works best for me : push(@peptides, $peptide = $_); Thanks a lot for your kind help. Best,