The ampersand (&) is the identifier used to call subroutines. Most of the time, however, subroutines can be used in an expression just like built-in functions. To
call subroutines directly:
name(args); # & is optional with parentheses
name args; # Parens optional if predeclared/imported
&name; # Passes current @_ to subroutine
To call subroutines indirectly (by name or by reference):
&$subref(args); # & is not optional on indirect call
&$subref; # Passes current @_ to subroutine
4.7.2 Passing Arguments
All arguments to a subroutine are passed as a single, flat list of scalars, and return values are returned the same way. Any arrays or hashes passed in these lists
will have their values interpolated into the flattened list.
Any arguments passed to a subroutine come in as the array @_.
You may use the explicit return statement to return a value and leave the subroutine at any point.
#!/usr/local/bin/perl -T
use strict;
use CGI;
my $obj = new CGI;
my $addoffers = $obj->param('addoffers');
print $obj->header,
$obj->start_html,
"AddOffers: $addoffers",
$obj->end_html;
If that cgi is at /path_to/server_root/cgi-bin/example.cgi,
you can call it and pass in a var like this,
--------------------------
You can also do it with a 'post', if you need. As long as yoururl is fairly short (< 256 bytes, i think ) a 'get' will work. 'hope this helps
If you are new to Tek-Tips, please use descriptive titles, check the FAQs, and beware the evil typo.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.