[ic] TrackSub is Broke?

Mike Heins mike at perusion.com
Sat Apr 30 23:00:46 EDT 2005

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 
> interchange.cfg
> 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.

Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <mike at perusion.com>

Nature, to be commanded, must be obeyed. -- Francis Bacon

More information about the interchange-users mailing list