in reply to Deleting specific array elements

If you never need these newline elements, i would avoid storing them in the first place.
@molecules = grep { $_ ne "\n" } split ...