Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Subphrases from a phrase

by sk (Curate)
on Aug 10, 2005 at 04:46 UTC ( [id://482512]=note: print w/replies, xml ) Need Help??


in reply to Subphrases from a phrase

Something like this -

#!/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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://482512]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-04-16 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found