in reply to Re: foreach (each character in string..)?
in thread foreach (each character in string..)?

I tried to send you a /msg, but I am unsure how to do so due to the space in your username. I have a quick pedantic note: you should probably s/array/list/ on your first sentence. 8^)

Even more pedantic is to point out that 0..length($string)-1 does indeed make a list, but I think we know what you meant. ;)

Update: I stand corrected. It might be noted that I knew there was an optimization with for and the range operator, but I thought it still ended up building a list -- I didn't realize it just turned into an iterator.

Replies are listed 'Best First'.
Re^3: foreach (each character in string..)?
by Roy Johnson (Monsignor) on Jan 20, 2004 at 20:35 UTC
    Yes, I am a bit loose in calling lists arrays. But note that in a foreach, the .. operator with integer operands does NOT create a list. It acts as an iterator. This is a special optimization introduced in 5.005.

    The PerlMonk tr/// Advocate