#!/usr/bin/perl -w use strict; my %hash = (); while () { # split based on spaces my ($hex, $foo, $int) = split /\s+/; # use hash value as an array ref push @{$hash{$hex}}, $int; }