#!/usr/bin/perl
use HTML::Template;
use MIME::Base64;
use Digest::HMAC_SHA1 qw(hmac_sha1);
my $template = HTML::Template->new(filename => 'cart.tmpl');
my @items;
my $key = '1234567899';
my $num;
while ($num < 10){
my %item = (item_name => "Bone Volume $num", item_descrip
+tion => "good stuff", quantity => "1", unit_price => "40.00");
push (@items, \%item);
$num++;
}
$template->param(items => \@items);
my $cart = $template->output;
my $ecart = encode_base64($template->output,'');
my $signature = encode_base64(hmac_sha1($cart, $key),$eol);
print "cart:$cart\nencoded cart:$ecart\nsignature:$signature\n";
It seems to do the job, thanks for the tip. |