in reply to passing variables between subroutines
&mailoff;
This syntax calls the named sub using the same @_ array as currently exists -- which doesn't since you aren't in a subroutine. Is that what you intended or are you just using the & calling style? (It is an older style held over from Perl 4 and generally not necessary unless you actually want to reuse @_.)
From reading the way your code is structured, it doesn't look like you're familiar with subroutine parameters. I think you might want to read perlsub, which talks about how subroutines pass arguments.
Here's some typical ways of passing and returning values:
sub some_function { my $arg1 = shift; # shift the first value off of @_ my ($arg2, $arg3, ) = @_; # or copy all of @_ at once # process stuff return $some_value; } # called like this $value = some_function( 1, 2, 3 );
For your problem, you probably want to store the result of IP_check and pass it to mailoff like this: mailoff( $ip_check_result ). mailoff will then need to shift the argument off of @_ as in the example above.
There are some other issues in your code around repeating my $info2, etc. -- you might want to also try use warnings as a learning tool
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: passing variables between subroutines
by budreaux (Initiate) on Jan 16, 2006 at 16:29 UTC | |
by blazar (Canon) on Jan 17, 2006 at 10:58 UTC |