Search::Dict(3perl)

πŸ’– Search::Dict πŸ’–

okay bestie, welcome to the Perl Programmers Reference Guide page for Search::Dict β€” yes, we're in section 3perl of the manuals, and this little cutie is the one whose whole job is: look β€” search for a key in a dictionary file πŸ¦‹


✨ NAME ✨

Search::Dict β€” look β€” search for key in dictionary file πŸŽ€


🌸 SYNOPSIS 🌸

use Search::Dict;
look *FILEHANDLE, $key, $dict, $fold;

use Search::Dict;
look *FILEHANDLE, $key, $params;

two ways to call her, pick your fighter πŸ’…


πŸ‘‘ DESCRIPTION πŸ‘‘

so what it does is it sets the file position in FILEHANDLE to be the first line greater than or equal to $key β€” and yes, that comparison is stringwise (we're doing strings here, not numbers, no cap).

It returns the new file position as its value. And if something goes wrong? It returns -1. 😭 an error happened, bestie, and it is telling you with a very sad little minus one.

The flags are the ones that decide dictionary order and case folding, so let's get into it:

  • $dict β€” if this one is true, we search by dictionary order, which means ignoring anything that isn't a word character or whitespace. The default is to honour all characters. (periodt, no filtering by default)
  • $fold β€” if this one is true, we ignore case. The default is to honour case, i.e. uppercase and lowercase are just different, deal with it πŸ’…

okay now the spicy part. If there are only three arguments and that third argument is a hash reference, then the keys of that hash can have the values "dict", "fold", and "comp" or "xfrm" (more on those below πŸ‘‡) β€” and the values hanging off those keys get used as the parameters. cute, right? πŸŽ€

so about those two special subroutines:

  • If a comparison subroutine (comp) is defined, it must return less than zero, zero, or greater than zero β€” depending on whether the first comparand is less than, equal to, or greater than the second comparand. That's the contract, bestie, don't break it 🫢
  • If a transformation subroutine (xfrm) is defined, its value gets used to transform the lines read from the filehandle before their comparison. so like, makeover first, compare later ✨

ngl the -1 on error is the only dramatic part of this whole module. everything else is just vibes and string comparison πŸ’€

and that's the whole page, bestie!! πŸ¦‹ this one came from perl v5.44.0, dated 2026-10-17, and it lives in the Search::Dict(3perl) corner of the manual. go forth and binary-search your dictionaries, main character πŸŒˆπŸ’–

πŸ“¦ where this page comes from
  • arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms