my @chapters = ( 15, 24, 23, 110, 30, 58, 3, 22, 79, 6 ); my $chapter = 1; my @sentenceToChapter = ( undef, # start counting at 1 map { ($chapter++) x $_ } @chapters, ); print qq{Sentence $_ is in chapter $sentenceToChapter[ $_ ]\n} for qw{ 250 15 16 98 };