in reply to Return a var from one sub to another
Or, you can use lists:sub foo { #... return { errno => 0, errmess => $msg }; } my $error = foo(); print $error->{errno}, $error->{errmess};
sub foo { #... return ( 0, $msg ); } my ( $errno, $errmess ) = foo();
Also, watch out for:
if ($var = 0) {
That's going to assign zero to $var. If you start all your scripts with:
use strict; use warnings;
perl will catch that for you (as well as many other errors & warnings).
update: used parentheses instead of braces. doh.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Return a var from one sub to another
by Luken8r (Novice) on Jul 10, 2007 at 23:07 UTC |