I'm trying to replace an element in my array and my code doesn't seem to work.
my @wholeloop = (split //, $loop);
for my $i (0 .. $#wholeloop ) {
if ( $wholeloop[$i] eq "i" ) {
$wholeloop[$i] =~ htmlinsert($offset);
$offset++
}
}
I've read about problematics of doing stuff while iterating through an array, and maybe is there a better solution. I'm trying to replace specific occurences of a character in a string, and array seemed as a reasonable tool to use.
$loop =~ s/([iaeou])/htmlinsert($1)/ge. Note that I have no idea what$offsetis in your code, and why you use it.