I can't figure out how you got that speed improvement. The
time you save by removing the /i flag is lost when you
build a large array in memory (45,000 words in my
machine). Besides, do you really think an
all-uppercase output is better?
$ time perl wsearch.pl owijfwapplelaskfiwejfcherryalkfwiofwfblossomowiejf
1 Al
2 apple
3 as
4 ask
5 blossom
6 cherry
7 err
8 he
9 her
10 Herr
11 Io
12 Los
13 loss
14 mow
15 of
16 so
17 we
0.30user 0.00system 0:00.30elapsed 99%CPU
$ time perl wsearch2.pl owijfwapplelaskfiwejfcherryalkfwiofwfblossomowiejf
1 AL
2 APPLE
3 AS
4 ASK
5 BLOSSOM
6 CHERRY
7 ERR
8 HE
9 HER
10 HERR
11 IO
12 LOS
13 LOSS
14 MOW
15 OF
16 SO
17 WE
0.48user 0.00system 0:00.48elapsed 99%CPU
Of course, I ran both scripts at least 4 times, to make sure that
the storable file was created and that both scripts were reading their
input from the disk cache.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|