in reply to Re: How do I read this line of code?
in thread How do I read this line of code?

TIMTOWTDI. I would never use a for loop for this, but it might well be a simplification of what in earlier versions warranted the for loop.

$buff .= $_ for "\n", ' ' x ( $level - 1 ), shift @pre_push; => { my $indent = " " x ($level - 1); $buf .= "\n" . $indent . shift @pre_push; } or $buff .= "\n" . (" " x ($level - 1)) . shift @pre_push; or $buff .= join "" => "\n", " " x ($level - 1), shift @pre_push; or $buff .= join ((" " x ($level - 1)) => "\n", shift @pre_push); or ...

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^3: How do I read this line of code?
by pmarcoen (Novice) on Sep 29, 2011 at 09:42 UTC

    Okay, this clarifies a lot, so there is no real need for a for loop.

    The for loop is not used to loop through the elements of the array, but rather to loop through the things we want to add to $buff being:

    1. a newline
    2. spaces
    3. the entire content of the array