Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: possible combinations in sequence

by QM (Parson)
on Jun 13, 2006 at 23:40 UTC ( [id://555138]=note: print w/replies, xml ) Need Help??


in reply to possible combinations in sequence

And for completeness, the glob solution, which spends more code fixing up the output than actually generating the results:
sub qm { my ($glob) = @_; my @rv; $glob =~ s/(\w+)/{$1,}/g; for my $combo (glob($glob)) { $combo =~ s/^:+//; next unless length($combo); push @rv, join ':', split /:+/, $combo; } return @rv; }
and is horribly slow as well.

BTW, it's interesting to note the change in benchmark results when the input is a long list of null strings:

$source = ':'x20;

-QM
--
Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-18 23:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found