in reply to reading dictionary file -> morphological analyser
From the context of the first block of code in your post, I assume that your code is acting as a CGI (or equivalent) script, which means you already have a web server environment. If this is indeed the case, you may benefit from a more server-like solution to your dictionary lookup problem. Your current flat-file dictionary database must be read entirely each time it is accessed (or at least read until the desired entry is found). If instead you stored it using a relationional database manager such as MySQL (recommended only because it is free and I don't know much about any others), then your lookup times should decrease dramatically. Then simply use the Perl DBI/DBM interface to query the database.