Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've written a little code to connect via the DICT protocol to webster's and retrieve a def for each word in the file "~/vocab_list". It works fine, but it returns multiple definitions for each word, etc. How can I match an entire paragraph rather than just a single line?
#!/usr/bin/perl -w use Net::DICT; #Clear "file" open (FILE, ">.vocab_file"); print FILE ""; close FILE; open (LIST, "vocab_list") || die "Missing vocab list?\n"; while ($word = <LIST>) { #Lookup definition... $dict = Net::DICT->new(); $dict->open('dict.org') || die "can't connect to dict.org: $!, " . $dict->errn +o() . "\n"; @def = $dict->define('!', $word); open (FILE, ">>.vocab_file"); foreach (@def) { print FILE "$$_[3]"; } close FILE; $dict->quit; } close LIST;

Replies are listed 'Best First'.
Re: string matching/dictionary
by CukiMnstr (Deacon) on Apr 09, 2002 at 22:06 UTC
    maybe I'm half asleep, but I can't see the relation between your question "How can I match an entire paragraph rather than just a single line?" and the code posted...

    anyway, if you want a multi-line regex match, =~ m//, then you could use the 'm' modifier for your regex. Check perlop (search for m/PATTERN/).

    hope this helps,