Extract last K characters from a string in Perl
I have a string that looks like this
my $str1 = "ACGGATATTGA"; my $str2 = "alex";
What I want to do is to extract last three characters from each of that.
$out1 = "TGA"; $out2 = "lex";
How can I do it in Perl?
$out1 = substr($str1, -3);