I would suggest against writing your own inverted index code. There are lot of good full-text index engines out there... For perl-only implementation, see Plucene or KinoSearch.
in reply to Writing a Search Engine in Perl?
For hybrid C-perl combination I would suggest http://hyperestraier.sourceforge.net/ for which I plan to write perl-only P2P API (help appriciated).
Somewhat off-topic, but there is also (shameless plug) http://pgfoundry.org/projects/pgestraier/ for quering HyperEstraier index directly from PostgreSQL to have best of both worlds: structured data in PostgreSQL which is joinable with full-text results from HyperEstraier. It will probably include P2P API in near future.