my $input = 'rnbqkbnr'; my $search = 'n'; my @results = grep substr( $input, $_, 1 ) eq $search, 0 .. length $input; print @results; 1 6