my $data = input(); foreach my $info (@$data) { # do other stuff } # ------------------ sub input { my @data; # do stuff return \@data; }