[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] TrackSub is Broke?


Quoting Duane Hinkley (suppressed):
> 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';
> }
> EOR
> 
> 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 || '';
	}
}
EOS

AddDirective  TrackSub customtrack

Then in your catalog.cfg:

Sub <<EOR
sub trackfoo {
   Log("Called trackfoo");
}
EOR

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 <suppressed>

Nature, to be commanded, must be obeyed. -- Francis Bacon
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.