[ic] Cleaning up my code?

Mike Heins interchange-users@icdevgroup.org
Wed Sep 11 12:01:12 2002


Quoting marc.brevoort (marc.brevoort@armazemdedados.com):
> Hi group,
> 
> In the Interchange project that I'm working on, the pages that I'm working on 
> are starting to contain lots and lots of Perl code, to the point where 
> finding back a particular piece of code takes a lot of scrolling in the file.
> 
> I'd like to move some subroutines to external files. Unfortunately 'use' and 
> 'require' are disabled by default by IC's 'safe' mode. Also, a 'sub' defined
> in one perl block is out of scope to the next one. Thus, using the 'include' 
> tag does not seem to be very useful.

This is not true. A sub defined is in scope for the entire page, and
in fact in any point forward in time from that, even in an AutoEnd.
It is defined in the Safe compartment and will not go away.

> 
> Does anyone have similar issues? What have you done about it?
> 

I use include, or global UserTag routines with external library
modules.

And you can make a library in catalog.cfg:

Sub library <<EOR
sub {
	sub foo { return 'foo' }
	sub bar { return 'bar' }
}
EOR

Then in the page:

    [perl]
	return foo() . bar();
    [/perl]

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

I have a cop friend who thinks he ought be able to give a new ticket;
"too dumb for conditions".