Thanks for your answers. Switching to a for solved that problem (I could not have rewritten it with a simple loop, as I have a lot of when in a Lex-like code).
If I understand correctly the fact that in v5.16 the same code gives an infinite loop, it's that the given's version of $_ have been "fixed", in the sense that a new scalar is now created for each iteration (hence the pos() function and the matching are in accord). But the same thing with the for loop will still work as I expect ?
If the when construct does not care from where does the $_ variable comes from, do you know what was the need to introduce given rather than just stick with for ?
Anyway, thanks for your help!
In reply to Re^2: Using pos() inside given/when
by Anonymous Monk
in thread Using pos() inside given/when
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |