Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 679461
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:15:44+00:00 2026-05-14T01:15:44+00:00

I want to do permutation in Perl. For example I have three arrays: [big,

  • 0

I want to do permutation in Perl. For example I have three arrays: ["big", "tiny", "small"] and then I have ["red", "yellow", "green"] and also ["apple", "pear", "banana"].

How do I get:

["big", "red", "apple"]
["big", "red", "pear"]

..etc..

["small", "green", "banana"]

I understand this is called permutation. But I am not sure how to do it. Also I don’t know how many arrays I can have. There may be three or four, so I don’t want to do nested loop.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:15:44+00:00Added an answer on May 14, 2026 at 1:15 am

    That’s actually not permutation but Cartesian product. See Math::Cartesian::Product.

    #!/usr/bin/perl
    
    use strict; use warnings;
    
    use Math::Cartesian::Product;
    
    cartesian { print "@_\n" }
        ["big", "tiny", "small"],
        ["red", "yellow", "green"],
        ["apple", "pear", "banana"];
    

    Output:

    C:\Temp> uu
    big red apple
    big red pear
    big red banana
    big yellow apple
    big yellow pear
    big yellow banana
    big green apple
    big green pear
    big green banana
    tiny red apple
    tiny red pear
    tiny red banana
    tiny yellow apple
    tiny yellow pear
    tiny yellow banana
    tiny green apple
    tiny green pear
    tiny green banana
    small red apple
    small red pear
    small red banana
    small yellow apple
    small yellow pear
    small yellow banana
    small green apple
    small green pear
    small green banana
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example, I have 3 counters (which I essentially want to represent as truth
i have two n in c++ and i want to generate permutation of the
I want to build a list containing every possible permutation of capitalization of a
What I want to do is to find every permutation of a 1-d array
want to have a Hyperlink-Button in a gridView in which I can display a
Want the function to sort the table by HP but if duplicate HPs then
I have read something in the site that inversion means if i<j then A[i]>A[j]
I want to generate a permutation of an array a and I don't want
Suppose you have an NxN grid, and you want to visit every cell exactly
I have an array of arrays. The inner array is 16 slots, each with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.