in reply to Return a var from one sub to another

You could use a hashref (which you're nearly doing):

sub foo { #... return { errno => 0, errmess => $msg }; } my $error = foo(); print $error->{errno}, $error->{errmess};
Or, you can use lists:

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
    Thanks for the tips. Ill give that a shot