my $text = 'The quick red fox jumped over the lazy brown dog'; my $search = 'quick'; my $location = index($text, $search); if ($location < 0) { print "$search not found!\n"; } else { print "$search found $location bytes from the front" . ("!"x$location), "\n"; }