mashficool has asked for the wisdom of the Perl Monks concerning the following question:
Please let me know if anyone can give me that one line code that I need to put in my perl program that will really help me with my school homework.
I am very new to perl and struggling to write this simple program.
I have to write a CGI program that, given a user-specified search string, finds all words
(based on my /usr/share/dict/words file) that match this search string.
For example if I type " AN " in the search panel, the program will show me the related words from the dict file:
ANomaly
ANatomy
ANonymously
If I type "JAN" in the search panel, the program will show me:
JANuary
JANet
JANmiller
and so on ..
So far I came up with these set of codes:
$search='an'; open(W,"/usr/share/dict/words); while (<W>) { print if m/$search/; }
but it only searches for "an". What if I want to search for any word ?? What would the search string be ?
Help please
------------------------------------------------
Please help me. Regards, Mash
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Need Simple Perl Help plz
by Joost (Canon) on Jun 12, 2006 at 22:33 UTC | |
|
Re: Need Simple Perl Help plz
by ikegami (Patriarch) on Jun 12, 2006 at 22:34 UTC | |
|
Re: Need Simple Perl Help plz
by merlyn (Sage) on Jun 12, 2006 at 23:14 UTC | |
by jpeg (Chaplain) on Jun 12, 2006 at 23:24 UTC |