in reply to Re: Finding all substrings
in thread Finding all substrings

AFAIK the code between parens in the foreach statement is executed just once to obtain a list over which to iterate.
So yours is not really an optimization.
Update: i see now your and suaveant point as the inner loop get called multiple times: the original post was not that clear.

$|=$_='1g2i1u1l2i4e2n0k',map{print"\7",chop;select$,,$,,$,,$_/7}m{..}g

Replies are listed 'Best First'.
Re: Re: Re: Finding all substrings
by suaveant (Parson) on Apr 24, 2002 at 18:13 UTC
    Very true... but the inner foreach loop gets called multiple times... so there would be a bit of savings... certainly good advice in this case... in a single for loop it would make no difference.

                    - Ant
                    - Some of my best work - (1 2 3)