in reply to How can one create an array of the indices at which a given character appears in a string?

See index.
#!/usr/bin/perl use warnings; use strict; my $input = 'rnbqkbnr'; my $search = 'n'; my @positions; my $pos = 0; while ($pos = 1 + index $input, $search, $pos) { push @positions, $pos - 1; } print "@positions\n";
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
  • Comment on Re: How can one create an array of the indices at which a given character appears in a string?
  • Download Code

Replies are listed 'Best First'.
Re^2: How can one create an array of the indices at which a given character appears in a string?
by tkguifan (Scribe) on Jan 29, 2015 at 14:06 UTC
    Nice.