Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Finding all substrings

by giulienk (Curate)
on Apr 24, 2002 at 18:08 UTC ( [id://161702]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://161702]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 19:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found