themage has asked for the wisdom of the Perl Monks concerning the following question:
Hi Enlighted Ones,
I'm here looking for wisdom from you. I have an expression, and I need the expressions contained in that. For example, if I have:
I'm here looking for wisdom from you. I have an expression, and I need the expressions contained in that. For example, if I have:
I would like to get:camel perl book
camel perl book camel perl perl book camel perl book
I made this small sub that returns the pretended list, but I would like to know your opinions on that:
There is any better way to do this?
Thank you very much for sharing your wisdom.
This is intented to create a query for a payperview search engine, where the records which search expression is complete in the query will be shown.sub list { my $words=shift; chomp $words; my @words=split /\s/, $words; my @longs=(); for my $i (1..$#words-1) { push @longs, map { join " ", @words[$_..$_+$i]} (0..$#words-$i); } push @words, @longs,$words; return @words; }
There is any better way to do this?
Thank you very much for sharing your wisdom.
TheMage
http://themage.bliker.com
http://themage.bliker.com
Back to
Seekers of Perl Wisdom