tkguifan has asked for the wisdom of the Perl Monks concerning the following question:
Is there a shortcut to do it more simply?my $input='rnbqkbnr'; my $search='n'; my $index=0; my @result; foreach(split //,$input) { if($_ eq $search) { push(@result,$index); } $index++; } print "Result: ",join(' , ',@result);
|
|---|