How to format text data for a simple Perl dictionary?

I have a very simple vocabulary app that searches and displays. It is built with a module Win32::GUI. I put all the text data needed for the dictionary in the section __DATA__. The script itself is very small, but with everything in the section __DATA__, its size reaches 30 MB. To share the work with my friends, I packed the script into a standalone executable file using the PP module utility PAR::Packerwith the highest compression level of 9, and now I have a dictionary with one application file about 17 MB in size.

But, although I really like the idea of ​​a single-file script, placing such a huge amount of text data in a DATA script section does not seem right. Firstly, when I try to open a script in Padre (Notepad ++ is ok), I get an error that is similar:

Can't open my script as the script is over the arbitrary file size limit which is currently 500000.


My questions:

Does this bring me additional benefits, except for fixing the problem of opening the Padre file, if I translate everything in the DATA section into a separate text file?

If I do this, what should I do to reduce the size of a single file? Freeze it and unzip it while searching and displaying?

How do people usually format the text data needed for a dictionary application?

Any comments, ideas or suggestions? Thanks, as always :)

+5
source share
2

, , ? ?

, , . ( ), zip/unzip - .

, , (, ) .

, ?

IMHO , ( ): , , .

, , - , SQLite DBL DBK .

, Padre, DATA ?

... script, , .

, ( - ).

, , .

+2

PAR::Packer , PAR?

( pp, use ):

words.pl

#!/usr/bin/perl

use strict;
use warnings;

use Words;

for my $i (1 .. 2) {
    print "Run $i\n";
    while (defined(my $word = Words->next_word)) {
        print "\t$word\n";
    }
}

Words.pm

package Words;

use strict;
use warnings;

my $start = tell DATA
    or die "could not find current position: $!";

sub next_word {
    if (eof DATA) {
        seek DATA, $start, 0
        or die "could not seek: $!";
        return undef;
    }
    chomp(my $word = scalar <DATA>);
    return $word;
}

1;

__DATA__
a
b
c
+2

All Articles