[ic] TrackSub is Broke?

Duane Hinkley duane at downhomewebdesign.com
Sun May 1 11:51:17 EDT 2005

Mike Heins wrote:

>Quoting Duane Hinkley (duane at downhomewebdesign.com):
>>I'd like to use the option in the Track.pm module to define my own 
>>subroutine to save the tracking information but it appears to be broke 
>>or just impossible to do.  I've tried about every way I can think of to 
>>define TrackSub in my catalog.cfg file so $Vend::Cfg->{TrackSub} 
>>containing a reference to a subroutine.  There's no way to make it work.
>>What get's me the closest to working is putting the following in 
>>AddDirective  TrackSub
>>Then I put the following in catalog.cfg;
>>TrackSub customtrack
>>TrackSub <&EOR
>>sub {
>>   return 'test';
>>That gives me the following error:
>>Runtime error: Can't use string ("test") as a subroutine ref while 
>>"strict refs" in use at /usr/lib/interchange/lib/Vend/Track.pm line 188.
>>Could someone let me know how to define a subroutine ref to make this 
>>work?  Or is this just broke?
>I had never used it, so I didn't know about the mechanism. It
>seems to me this in interchange.cfg is the only (relatively)
>easy way to do it:
>GlobalSub hook_to_parser <<EOS
>sub {
>	sub parse_customtrack {
>		my ($var, $name) = @_;
>		my $sub = $C->{Sub}->{$name} || $Global::GlobalSub->{$name};
>		return $sub || '';
>	}
>AddDirective  TrackSub customtrack
>Then in your catalog.cfg:
>Sub <<EOR
>sub trackfoo {
>   Log("Called trackfoo");
>TrackSub trackfoo
>The TrackSub can then be the name of a GlobalSub or a Sub -- it needs
>to open and write a file or program to do something useful, of course.
Wow, Mike.  I would have never figured that one out. 

If I changed the Track.pm to use the same method for defining the 
subroutine to use as the Payment.pm uses to call the payment modules, 
that seems like a simpler way for future users to plug in a custom 
tracking module.  Then they would just have to pass the name of the 
module to use.

Would that work better?



Duane Hinkley
Down Home Web Design, Inc.
(208) 424-0572 Fax(208) 587-0738

duane at downhomewebdesign.com

More information about the interchange-users mailing list