in reply to a farewell to chop

I like using chop to do this sort of thing (I am a bioinformaticist):

my $dna = 'gagagtatgcgattaatgcatattataaaaagcggcatgacggca'; for (1..10) { my $base = chop($dna); print "$base\n"; }
Regards,

Helgi Briem

Replies are listed 'Best First'.
Re^2: a farewell to chop
by Aristotle (Chancellor) on Sep 12, 2002 at 14:53 UTC
    You can do better without chop there, though.. print "$_\n" for reverse split //, substr($dna, -10); And if you need $dna to loose the last characters, print "$_\n" for reverse split //, substr($dna, -10, 10, ''); Brackets not necessary here, but added for readability.

    Makeshifts last the longest.