in reply to Re: How to not print the same random number
in thread How to not print the same random number

You can eliminate the manifest temporary by:

($p->[$_], $p->[$swap]) = ($p->[$swap], $p->[$_]);

Note though that it is slower:

use strict; use warnings; use Benchmark qw(cmpthese); my @arr = 1..2; cmpthese (-1, { temp => sub {my $temp = $arr[0]; $arr[0] = $arr[1]; $arr[1 +] = $temp;}, swap => sub {($arr[0], $arr[1]) = ($arr[1], $arr[0]);}, } ); Rate swap temp swap 1381331/s -- -43% temp 2425611/s 76% --

DWIM is Perl's answer to Gödel