while (my ($a,$b,$c) = splice(@data, -3)) { push @hashrefs, { a => $a, b => $b, c => $c }; pop @data; # null field } #### my @hashrefs; $#hashrefs = int(@data / 4); my $i = $#hashrefs; while (@data and my ($a,$b,$c) = splice(@data, -3)) { $hashrefs[$i--] = { a => $a, b => $b, c => $c }; pop @data; }