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


in reply to Re^2: Passing a reference from a subroutine.
in thread Passing a reference from a subroutine.

The syntax is clearly correct (as shown in the example below). So if you're getting the proper data with Dumper in your for loop, then you're likely damaging the data between the Dumper call and your return statement.

$ cat t.pl #!/usr/bin/perl use strict; use warnings; sub get_data { my $data = shift; my @AoA = (1 .. $data); return \@AoA; } my $aref = get_data(5); print join(", ", @$aref), "\n"; marco@Boink:/Work/Perl/Sudoku $ perl t.pl 1, 2, 3, 4, 5

...roboticus

When your only tool is a hammer, all problems look like your thumb.