note blazar <strike><c> my \$pos; for (0..\$#array) { \$pos=\$_ and last if \$array[\$_] eq \$wanted; } @array[\$pos,-1]=@array[-1,\$pos]; </c> <p>And what if no one of them matched? (Left as an exercise to the reader)</p></strike> <p><strong>Update:</strong> it was a <em>wonderfully neat</em> solution (which is the reason why I posted it!) to <em>another problem!!</em></p> <p>Not just as neat:</p> <c> my \$pos; for (0..\$#array) { \$pos=\$_ and last if \$array[\$_] eq \$wanted; } @array=@array[0..\$pos-1, \$pos+1..\$#array, \$pos]; </c> <p>And what if no one of them matched? (Left as an exercise to the reader ;-)</p> <p>But then if you are sure in advance that one and only one element will match, here's a neat concise solution: <c> @array=((grep \$_ ne \$wanted, @array), \$wanted); </c> You can patch it so that it works also if the above conditions are not verified, but won't be just as elegant. (Also left as an exercise to the reader!)</p> <spoiler> <p>Solution:</p> <c> @array = do { my \$i; (grep \$i || \$_ ne \$wanted || \$i++, @array), \$i ? \$wanted : (); }; # or, as a sub: sub move { my (\$wanted, \$i)=shift; (grep \$i || \$_ ne \$wanted || \$i++, @_), \$i ? \$wanted : (); } </c> </spoiler> 509310 509310