MiniVend Akopia Services

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

Trouble getting piece of perl script working HELP!



Hello.

I have following piece of perl code in my page, which I use
to calculate bank reference numbers. But for the life of me I just cant
get it working!

[perl scratch]
$receipt_nr = '123456';      

@multipliers = (7,3,1);

if ($receipt_nr =~ /([0-9]*)/)
{
    $receipt_nr = $1;
}
        
$i = (length $receipt_nr) - 1;
        
if ($i < 0 or $i > 20)
{
    exit;
}

@merkit = split //,$receipt_nr;
         
$k = 0;
$sum = 0;

for ($j=$i; $j > -1;$j--)

{
    if ($k == 3) { $k=0 };
    
    $sum = @merkit[$j] * @multipliers[$k] + $sum;
    $k++;
}

$tens = 0;

while ($tens <= $sum)
{
    $tens = $tens + 10;
}

$checksum = $tens - $sum;

$bank_ref = join '',$receipt_nr,$checksum;
$Safe{'scratch'}{'ref'}=$bank_ref;

[/perl]

When I run the same code as a normal perl script it works fine.

But on minivend it just doesn't work!

I try to output it using following tag
Reference   : [scratch ref]

I'm using 
Minivend 3.14-3
Linux (Redhat 6.0)
Perl 5.005_03
Apache 1.39

If I try just some simple test routine, everything works fine.
What I'm doing that minivend cant digest?

And does anyone know any alternative way of doing some calculating in
minivend?
For example calling external java program (I prefer java over perl)



Things I've tried

[perl args=sratch]

Following user tag in minivend.cfg

UserTag realperl   HasEndTag
UserTag realperl   CanNest 
UserTag realperl
Interpolate
UserTag realperl   Routine <<EOF
sub {
    my $str = eval {

    eval $_[0] or die;
    };                        
}
EOF

and then 
[realperl]
[perl scracth]
....






Search for: Match: Format: Sort by: