[ic] Subroutines and ActionMaps

Mike Heins interchange-users@icdevgroup.org
Mon Jan 27 09:23:01 2003


Quoting Mark Gibson (gibsonm@cromwell-tools.co.uk):
> Hello again,
> 	I've come up against another brick wall while attempting to make
> use of the ActionMap feature.
> 
> Where would I define a subroutine that I wish to call from within an 
> ActionMap?
> 
> I've tried the 'Sub' directive, eg:
> 
> Sub <<EOF
> sub do_stuff {
> 	...
> 	return $myresult;
> }
> EOF
> 
> ActionMap myaction <<EOF
> sub {
> 	...
> 	my $stuff = do_stuff();
> 	...
> }
> EOF
> 
> When I go to the URL (http://.../myaction) I just get the message:
> 
> Sorry, there was an error in processing this form action. Please report the 
> error or try again later. (Undefined subroutine &main::do_stuff called at 
> (eval 1783) line 4. )

That sub is not available in that context. You can do this, though:

ActionMap myaction <<EOF
sub do_stuff {
	...
	return $myresult;
}

sub {
	...
	my $stuff = do_stuff();
	...
}
EOF

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

How far can you open your mind before your brains fall out?