#!/usr/bin/perl use strict; use warnings; my %hash = (); my $key; while( ) { chomp; if( /^(\S.*)/ ) { $key = $1 } elsif( /^\s+(\S.*)/ ) { push @{ $hash{$key} }, $1 } elsif( /^\s*$/ ) { next; } } use Data::Dumper; print Dumper( \%hash ); __DATA__ Honda Civic Accord Toyota Camry Corolla Tundra Nissan Maxima