#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $HASH; my $Title; while ( ) { chomp; next if ! $_; if ( /^\d+\.(.*)/sg ) { $Title = $1; $HASH->{$Title} = []; next; } if ( exists $HASH->{$Title} ) { push @{$HASH->{$Title}} , $_; } } print Dumper($HASH); __DATA__ 1.TITLE OF FIRST RECIPE abstract Recipe 1. Recipe 2. Recipe ... Procedure... 2.TITLE OF SECOND RECIPE ...