in reply to Performance of Perl references

I think you're not understanding what references do. In your example, you are not comparing slinging a bunch of data around vs. using a reference, you are comparing directly accessing a lexical variable vs. de-referencing the same variable and then accessing. I would expect the de-ref to always be slower.

There are tons of reasons to use references, but if you want to see the speed advantages of them, bench something like this:

#!/usr/bin/perl -w use Benchmark; my @array; for (0..1000) { $array[$_] = rand(1000); } timethese(200, { 'ref' => sub { my @unsorted = @array; my $return_ref = sort_array_ref(\@unsorted); }, 'old skool' => sub { my @unsorted = @array; my @return_array = sort_array(@unsorted); }, }); sub sort_array_ref { my $array_ref = shift; my @sorted_array = sort @{$array_ref}; return \@sorted_array; } sub sort_array { my @array = @_; my @sorted_array = sort @array; return @sorted_array; } __END__ Benchmark: timing 200 iterations of old skool, ref... old skool: 6 wallclock secs ( 5.81 usr + 0.01 sys = 5.82 CPU) @ 34 +.36/s (n=200) ref: 6 wallclock secs ( 5.07 usr + 0.01 sys = 5.08 CPU) @ 39 +.37/s (n=200)