Say I have a hash:
1 => 1
2 => abc
3 => xyz
In Perl, how can I give a string like 211, and get all the possible combinations according to that hash: abc11, 1abc1, 11abc etc…
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There are several list permutation modules on CPAN, many in the question linked above: How can I generate all permutations of an array in Perl?
Using the List::Permutor module:
which prints:
Do note that you will have problems using bare numbers in your template if you go beyond the keys
0 .. 9. (does10mean10or1,0…). You should probably change your template to have a record separator.