It looks like it is from "Beginning Perl" by Curtis Poe. Page 300 has the whole program, page 301 discusses is_prime() which is non-optimized trial division (checks divisibility by all integers up to sqrt(n)). Page 302 discusses the code in question which is introducing using a hash to cache the result.
In particular, the test suite includes duplicates in its list. That's why the hash is used.
In reply to Re^3: Unable to Understand grep and hash use for prime no.
by danaj
in thread Unable to Understand grep and hash use for prime no.
by shankonit
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |