http://qs321.pair.com?node_id=150812


in reply to reversing substr

It's not quite clear what you're trying to do, especially since substr does accept a negative offset. What do you mean when you say "that doesn't work"?

If you want the first two characters of the string, try this:

my $str = "12345"; my $ss = substr($str, 0, 2); print $ss;
Or, if you want all but the last two characters, try this:
my $str = "12345"; my $ss = substr($str, 0, -2); print $ss;