#!/usr/bin/perl use strict; use warnings; my @words = qw(Camel Perl Book); for my $phrase_length (1..@words) { for my $start_idx (0..(@words-$phrase_length)) { print "@words[$start_idx .. ($start_idx + ($phrase_length - 1))]\n"; } }