my $bigStr = 'Once upon a time there was a little programer'; my $littleStr = 'time'; if ($bigStr =~ /^(.*?)$littleStr/) { my $position = length($1); print "Found $littleStr at position $position\n"; # Do whatever depending on the position returned }