in reply to Iterating over an array variable times

I ran the code above and got this:
A,B,C,D,E,F N,N,A,B,C,D,E,F N,A,N,B,C,D,E,F N,A,B,N,C,D,E,F N,A,B,C,N,D,E,F N,A,B,C,D,N,E,F N,A,B,C,D,E,N,F N,A,B,C,D,E,F,N A,N,N,B,C,D,E,F A,N,B,N,C,D,E,F A,N,B,C,N,D,E,F A,N,B,C,D,N,E,F A,N,B,C,D,E,N,F A,N,B,C,D,E,F,N A,B,N,N,C,D,E,F A,B,N,C,N,D,E,F A,B,N,C,D,N,E,F A,B,N,C,D,E,N,F A,B,N,C,D,E,F,N A,B,C,N,N,D,E,F A,B,C,N,D,N,E,F A,B,C,N,D,E,N,F A,B,C,N,D,E,F,N A,B,C,D,N,N,E,F A,B,C,D,N,E,N,F A,B,C,D,N,E,F,N A,B,C,D,E,N,N,F A,B,C,D,E,N,F,N A,B,C,D,E,F,N,N
Is this what you wanted? What does that represent? How is that useful to you? Needless to say, you always want use strict; use warnings; in your code.

Replies are listed 'Best First'.
Re^2: Iterating over an array variable times
by gingaloon (Acolyte) on Aug 05, 2008 at 15:31 UTC
    The output is what I wanted and I apologise for not pasting in the opening lines of a longer script.

    I have a string of letters, e.g. 'ABCDEF'. I want to insert the letter 'N' into each position so I can end up with:

    NABCDEF
    ANBCDEF
    ABNCDEF
    ...
    ABCDEFN
    

    At other times I'll need to insert a second N into the string, which is the output given in a previous post:

    NNABCDEF
    NANBCDEF
    ...
    ABCDEFNN
    
    Whether I need one or two iterations is controled by an input that we can call $num.

    I can do this insertion for one instance and also for two instances, but I've written them as two sets of code. I'm wondering if there's a way to do it in once block of code.

    many thanks