[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
[perl sub] syntax question
I am trying to write a routine to calculate insurance cost for UPS
shipping for our products. I followed the instructions in the
documentation and added the name of the routine at the end of the lines
for UPS. From some debugging printouts, I can tell that the routine is
being called. However, I can't pass anything to it.
The manual says that you can add a qualifying subroutine at the end of
each UPS line. It says that the subroutine will be called as if it was
within [perl sub] tags. I can't figure out what format that might be.
I have:
upsg ... u Ground [default zip 940] 2.00 round ups_insurance(@@COST@@)
(this is at the end of the line in shipping.asc). UPS shipping
calculations work correctly if I remove the last two elements on the line
above. I can tell that my routine ups_insurance (a GlobalSub) is being
called. However, when I do this in ups_insurance:
GlobalSub <<EOR
sub ups_insurance {
my $num_args = $#_;
::logGlobal("Number of args $num_args\n");
...
}
I get weird results. I get
blah blah blah... Number of args -1
in the error.log file! -1 ??
The documentation says that the arguments are passed to any shipping cost
qualifying routine as if they were encased in [perl sub] tags.
What is the format for that? The manual just says that they are between
the tags:
"If specified, the anchor text is a subroutine name and optional
parameters to be passed."
So, I changed my line in shipping to be:
u Ground [default zip 940] 2.0 round ups_insurance @@COST@@
Then, I get that $#_ is zero. I.e. no arguments were passed.
What is the format for [perl sub] ? Has anyone successfully added some
extra cost to UPS shipping? How can I do it? I thought this was the
right way, but after much searching in the manual, I am more confused than
before. The manual does not give an example of a [perl sub] call, so I
have no idea if I am guessing correctly on the syntax.
Any help would be appreciated.
Best,
Kyle