MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

How to use perl modules in minivend.



Hello.

I'm trying to use perl module called MD5 in my shop, and
even as I went trough the documentation I couldn't figure
what´s the correct way of declaring the module.

Here's an example that works in normal perl

#!/usr/bin/perl
use MD5;

$str='hello';
$md5 = new
MD5;

$md5->add($str);
$digest = $md5->digest();
$hex = unpack("H*",
$digest);
print "MD5(\"$str\") \ndigest: $digest\nhex: $hex\n";

And here's the best I've come up with as a minivend tag in catalog.cfg.

UserTag calc-md-checksum ORDER cleartext
UserTag calc-md-checksum ROUTINE <<EOR
use MD5;
sub
{
    my ($cleartext)=@_;
    my $md5 = new MD5;

    my $md5->add($cleartext);
    my $digest = $md5->digest();
    my $hex = unpack("H*", $digest);

    $Safe{'scratch'}{'mdchecksum'}=$hex;
    
}
EOR

Which doesn't seem to work. It doesn't give any errors when I restart
minivend,
but I dont get any output either. Actally it seems that if doesn't even
recognize it
as a user tag. 

I try to use it in a following manner
[calc-md-checksum cleartext='hello'] 

And output it with:
[scratch mdchecksum]

Does anyone have any suggestions, and does my attemp to utilize MD5 module
look correct?



Search for: Match: Format: Sort by: