in reply to prepend string to entire array

If you mean that you want "A1", "B2", C3", then this'll do it:
my @array2 = map "$array[$_]$array1[$_]", 0..$#array;

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

Replies are listed 'Best First'.
Re: •Re: prepend string to entire array
by mhearse (Chaplain) on Sep 10, 2003 at 01:55 UTC
    Works, but I need @array2 to contain all possible combinations. Such as:
    A1 B1 C1 D1 E1 F1 G1
    A2 B2 C2 D2 E2 F2 G2
    A3 B3 C3 ..........
      Um, don't you think you should have stated that in your orginal question? :|

      But i do find it amusing that you asked merlyn for code that does combinations. ;)

      UPDATE:
      Limbic~Region pointed me to Re: Character Combinations in which he links to a module tye wrote, Algorithm::Loops. Give it a look.

      jeffa

      I'm in a good mood.

      @array = qw(A B C D E F G); @array1 = qw(1 2 3 4 5 6 7); @array2 = map { my $c=$_;map "$_$c", @array } @array1;

      Hope this helps.

      antirice    
      The first rule of Perl club is - use Perl
      The
      ith rule of Perl club is - follow rule i - 1 for i > 1