misterperl has asked for the wisdom of the Perl Monks concerning the following question:

I have this expression:

delete $data->{"exclude-$k{$_->{name}}-$i++"} for @a;

which runs @a times as expected in dbg, but $i remains at it's initial value? Why doesn't $i++ increment each time?

Replies are listed 'Best First'.
Re: why wont $i increment?
by Corion (Patriarch) on Sep 08, 2023 at 12:21 UTC

    Because "$i++" is a string consisting of the value of $i and then ++. It is not a Perl expression.

    What you want might be

    delete $data->{"exclude-$k{$_->{name}}-" . $i++} for @a;
      ahh I see that now makes sense TY I voted++ you!