my ( $key, @data ); while ( ) { if ( /^([^:]+):/ ) { push @data, [ $_ ]; } else { push @{ $data[ -1 ] }, $_; } }