[ic] Subroutines and ActionMaps

Mike Heins interchange-users@icdevgroup.org
Mon Jan 27 12:13:01 2003


Quoting Mark Gibson (gibsonm@cromwell-tools.co.uk):
> On Monday 27 Jan 2003 2:53 pm, Mike Heins wrote:
> > One more note on this --- you can also call the Sub via:
> >
> > Sub <<EOF
> > sub do_stuff {
> > 	...
> > 	return $myresult;
> > }
> > EOF
> >
> > ActionMap myaction <<EOF
> > sub {
> > 	...
> > 	my $stuff = $Config->{Sub}{do_stuff}->();
> > 	...
> > }
> > EOF
> 
> I'm having another problem regarding 'Sub', they don't seem to work in
> [perl] blocks.
> 
> Lets assume we have defined the do_stuff() sub as above.
> The following doesn't work (within an HTML page):
> 
> [perl] return do_stuff(); [/perl]
> 
> I keep getting (in global error log):
> Safe: Undefined subroutine &main::do_stuff called at (tag 'perl') line 1.
> >
> > return do_stuff();
> >
> 
> BUT, the following works fine:
> 
> [perl] return $Config->{Sub}{do_stuff}->(); [/perl]
> 

Also, I noted that the strategy you found for accessing tables works
well for subs:

Sub <<EOF
sub do_stuff {
	...
	return $myresult;
}
EOF

ActionMap myaction <<EOF
sub {
	...
	$Tag->perl( { tables => 'products', subs => 1 });
	my $stuff = do_stuff();
	...
}
EOF

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

When the only tool you have is a hammer, all your problems tend to look
like nails.  -- Abraham Maslow