#!/usr/bin/perl use strict; use warnings; my @phrase = qw(Camel Perl Book); my @subph = (); while(@phrase) { @subph = subphrases(@phrase); print +($_,$/) for (@subph); shift(@phrase); } sub subphrases { my $i = 0; my @sph = (); my @ph = (@_); while ($i < @phrase) { $sph[$i] = join (' ', map { $ph[$_]} (0..$i)); $i++; } return (@sph); } __END__ Camel Camel Perl Camel Perl Book Perl Perl Book Book
In reply to Re: Subphrases from a phrase
by sk
in thread Subphrases from a phrase
by themage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |