You are viewing a plain text version of this content. The canonical link for it is here.
Posted to asp@perl.apache.org by Charlie Farinella <cf...@appropriatesolutions.com> on 2002/09/09 18:28:15 UTC
Passing form input to subroutine
I'm passing parameters from a form to a result page, and then trying to
call a subroutine from an external package to process the variable.
I'm using $Request->Form to get the value from the form to the result
page, but my subroutine is unable to make use of it. What is required
to make the subroutine aware of the variable?
--
------------------------------------------------------------------------
Charlie Farinella, Appropriate Solutions, Inc.
cfarinella@AppropriateSolutions.com
603-924-6079
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Passing form input to subroutine
Posted by Brat Wizard <br...@naxs.com>.
In my applications, I generally scoop up the form into a hash and then pass it
as a hash ref. eg:
my $form = $Request->Form();
myfunc($form);
sub myfunc {
my $form = shift;
print "Use like this: ", $form->{key};
print "Or like this: ", $$form{key};
}
Hope this helps
John
On Monday 09 September 2002 01:24 pm, Josh Chamas spewed into the ether:
> Charlie Farinella wrote:
> > I'm passing parameters from a form to a result page, and then trying to
> > call a subroutine from an external package to process the variable.
> >
> > I'm using $Request->Form to get the value from the form to the result
> > page, but my subroutine is unable to make use of it. What is required
> > to make the subroutine aware of the variable?
--
--------------------------------------------------------------------------------
Check out http://www.Wizard.Org for great deals on Electronic Parts
*NEW* Computer Parts & Accessories - Drives - LCD - Systems - Linux
--------------------------------------------------------------------------------
** Affordable Online Store w/Merchant Card Processing & Paypal **
Write to us: sales@wizard.org -- Get your Store Online Today!
--------------------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org
Re: Passing form input to subroutine
Posted by Josh Chamas <jo...@chamas.com>.
Charlie Farinella wrote:
> I'm passing parameters from a form to a result page, and then trying to
> call a subroutine from an external package to process the variable.
>
> I'm using $Request->Form to get the value from the form to the result
> page, but my subroutine is unable to make use of it. What is required
> to make the subroutine aware of the variable?
>
You can do $main::Request->Form from any perl package,
or if you have GlobalPackage set to something like MyPackage,
you can do $MyPackage::Request->Form. This inherently makes
your package aware of ASP type variables, which might be bad design.
You might better do something like &My::sub($Request->Form) when
you call it from the ASP script in the first place. Request->Form
is just a hash ref so is pretty ASP independent, and the params
could come from anywhere.
Regards,
Josh
________________________________________________________________
Josh Chamas, Founder phone:925-552-0128
Chamas Enterprises Inc. http://www.chamas.com
NodeWorks Link Checking http://www.nodeworks.com
---------------------------------------------------------------------
To unsubscribe, e-mail: asp-unsubscribe@perl.apache.org
For additional commands, e-mail: asp-help@perl.apache.org