johngg@shiraz:~ > perl -Mstrict -Mwarnings -E ' my $find = q{thatpart}; say $find; my $str = q{ksguhdipghisosipghthispartudirlhgdr}; say $str; my $posn = index $str, $find; die qq{Substring not found\n} if $posn == -1; my $idNo = substr $str, $posn, length $find, q{}; say $idNo; say $str;' thatpart ksguhdipghisosipghthispartudirlhgdr Substring not found