#!/usr/bin/perl # http://perlmonks.org/?node_id=1142125 use strict; use warnings; sub glob_array { my @ans = @{pop()}; @ans = map{ my $i = $_; map $i.$".$_, @ans } @{pop()} while @_; \@ans; } my @colors = qw(red green blue); my @directions = qw(north south east west); my @numbers = (1..3); my $array = glob_array( \@colors, \@directions, \@numbers ); use Data::Dump 'pp'; pp $array;