http://www.perlmonks.org?node_id=714845


in reply to results from pairs combination

Update: original posting changed massively in the mean time, so this is kinda out of context. In case of doubt just ignore it.

Do you always want to change the order of the last two elements? If yes

@pairs[-1, -2] = @pairs[-2, -1];

should work for you.