in reply to Strange substr behavior

AFAIK, this:

$DataRead{'StringRead'} = substr($DataRead{'StringRead'}, -3);
will set $DataRead{'StringRead'} to the last 3 characters of itself (or all if < 3 characters)... This:
substr($DataRead{'StringRead'}, -3) = '' ;
would remove the last three characters (or all if < 3 characters). Shirley ?

But in any case, would it not be easier to:

if ($DataRead{'StringRead'} =~ s/(\t|\n|\r|\e\[Z|\eq)\z//) { my $term = $1 ; .... } ;

Replies are listed 'Best First'.
Re^2: Strange substr behavior
by NateTut (Deacon) on Nov 20, 2008 at 19:25 UTC
    Thanks! I realize now that I forgot to include an offset for substr. I'm not sure how it ever worked. Also I like your suggestion.