Two things. First, I'm not sure why you're validating the remote address. In this chunk of code, there are a number of minor issues, and one larger issue. We'll start with a minor issue: using $ENV{REMOTE_ADDRESS} instead of CGI::remote_host(). It returns what you want, and, should some future CGI standard change how this gets passed around (say under a future mod_perl), you won't need to change anything to work with it - you'll just need to upgrade CGI.pm.
The major issue is the return keyword you're using. I'm not sure what you are attempting to do here. The return keyword is only useful inside a sub, and this doesn't seem to be inside a sub.
To answer your question, change &mailoff to mailoff($info2) (if that's the variable you're trying to pass). And then inside your mailoff sub, do this:
Note that the variable name we use inside mailoff is completely unrelated to the variable name we use to call mailoff with. They can be the same name, but I changed it to show that they commonly are different.sub mailoff { my $ip_address = shift; #open mail handler stuff print MAIL "here is the ip address $ip_address"; #close }
In reply to Re: passing variables between subroutines
by Tanktalus
in thread passing variables between subroutines
by budreaux
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |