#!/usr/bin/perl use 5.016; use warnings; my $str="This is a Hello World program"; $str=~/Hello/; say $-[0]; # $-[0] is the offset of the start of the last successful match. say $+[0]; # $+[0] is the offset into the string of the end of the entire match. $str=~/(This)(.*?)Hello(.*?)program/; say $str; say $+; # This returns the last bracket result