Читал, модули я поставил верно, но при интерпретации алгоритма(файл Huffman.pm) с cpan.org пишет: Not a HASH reference, и как мне исправить эту ошибку, и вообще должна ли она появлятся в подобном случае?
Мои предыдущие действия были такие:
1. Перешел по ссылке http://search.cpan.org/dist/Algorithm-Huffman/Huffman.pm скопировал в файл haffman.pl код с этого сайта:
Код:
use Algorithm::Huffman;
my %char_counting = map {$_ => int rand(100)} ('a' .. 'z', 'A' .. 'Z');
# or better the real counting for your characters
# as the huffman algorithm doesn't work good with random data :-))
my $huff = Algorithm::Huffman->new(\%char_counting);
my $encode_hash = $huff->encode_hash;
my $decode_hash = $huff->decode_hash;
my $encode_of_hello = $huff->encode_bitstring("Hello");
print "Look at the encoding bitstring of 'Hello': $encode_of_hello\n";
print "The decoding of $encode_of_hello is '", $huff->decode_bitstring($encode_of_hello), "'";
2. Установил через CPAN модуль Algorithm::Huffman
3. После команды: perl haffman.pl выдает код ошибки:
Код:
Not a HASH reference at /usr/local/share/perl/5.10.0/Algorithm/Huffman.pm line 198.
Вот собственно и вся ошибка.
Кому будет не сложно повторите эти действия, может дело в самом модуле Algorithm::Huffman и имеет смысл писать свой собственный?