[ic] Require in Global UserTag

Stefan Hornburg Racke interchange-users@interchange.redhat.com
Mon Sep 17 13:09:01 2001


mheins@redhat.com writes:


[...]

> > > 
> > 
> > This is a global usertag, so it resembles the get_url UserTag.
> > I suppose that I _should_ work, sigh.
> 
> No doubt you are calling it with 
> 
>     [perl]
> 	$Tag->chart(@parms);
>     [/perl]
> 

Accurate guess.

> Safe will not allow a runtime require, no matter what you do. You
> would need to do:
> 
> UserTag chart Routine <<EOF
> eval {
>     require GIFgraph::bars;
> };
> if($@) {
> 	return sub {
> 	    ::logError("Cannot generate chart, GIFgraph module not installed: $@");
> 	};
> }
> sub {
> 	# Do some stuff with GIFgraph::bars;
> }
> EOF

Thanks, Mike, this was really a time-saver. 

But I suggest to change the distributed tags accordingly.
There is IMHO no advantage for this check within
the sub.

Ciao
        Racke

-- 
Racke happily hacks Interchange and maintains Debian packages like Courier.

For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)