my %data; while () { chomp; my ($key, @values) = split /\s+/; $data{$key} = [ @values ]; } print $data{key2}->[1], "\n"; # prints: e __DATA__ key1 a b c key2 d e f key3 g h i