my $sub_str = "tftp>"; my $full_str = "# tftp> connect tftp.host.com 69"; my $i = index($full_str, $sub_str); # $i is 2