A few solutions from a previous thread with a similar problem.

@result = map scalar reverse, glob("{1,2,3,4,5,6,7}{A,B,C,D,E,F,G}"); # CheeseLord @result=map{$a=$_;map$a.$_,1..7}"A".."G"; # runrig @result=map$_.1..$_.7,"A".."G"; # tilly # which translates, in your case, into @result=map$_.$array1[0]..$_.$array1[$#array1],@array;

Update: extravagant solutions
broquaint complained in the CB that I haven't suggested any solutions based on Tree::DAG_Node. While I invite the curious reader to peek at Variant permutation, I propose here a gratuitously heavy DBI solution. :)

#!/usr/bin/perl -w use strict; use DBI; if (-f "permute") { unlink "permute" or die "can't unlink permute file\n" } my $dbh = DBI->connect("dbi:SQLite:permute", "","",{RaiseError=>1, PrintError=> 0 }) or die "Error in connecton ($DBI::errstr)\n"; my @array = ('A'..'G') ; my @array1 = ( 1 .. 7 ); $dbh->do(qq{CREATE TABLE t1 (a char(1)) }) or die "Error in table creation ($DBI::errstr)\n"; $dbh->do(qq{CREATE TABLE t2 (b char(1)) }) or die "Error in table creation ($DBI::errstr)\n"; $dbh->do("begin"); eval { my $sth = $dbh->prepare (qq{insert into t1 values (?)}); $sth->execute($_) for @array; $sth = $dbh->prepare (qq{insert into t2 values (?)}); $sth->execute($_) for @array1; }; if ($@) { $dbh->do("rollback"); die "error inserting\n"; } else { $dbh->do("commit"); } my $recs = $dbh->selectall_arrayref( qq{select a,b from t1,t2 }) # an infamous CROSS JOIN ! or die "error fetching records\n"; my @results; push @results, join( "", @$_) for @$recs; print "@results\n";
 _  _ _  _  
(_|| | |(_|><
 _|   

In reply to Re: prepend string to entire array by gmax
in thread prepend string to entire array by mhearse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.