in reply to why is substr behaving odd?

In addtion to !1's observation, if you were to turn on warnings(-w or use warnings) I'm wondering if the 'substr' line might not give you some grief about an undefined variable. Also keep in mind that substr is not going to 'pad' your result. So if there isn't 1000 bases(assumed to be 1 char each), you won't get substr 1000 long

.

## ## Taking the last N elements off the end of a string ## use strict ; use warnings ; my($s) = '0123456789' ; print substr($s, -5), "\n" ;