my $string = "hello world"; print $string =~ /(.{5})$/; #Or print $string =~ /.{5}$/g;