Ill make a guess it's a scope issue, but cant be sure without the main code.
Try something like use strict; my %test=mysub(); print %test; sub mysub { my(%myhash,$var1,$var2); $var1 = '1'; $var2 = '2'; $myhash{$var1} = $var2; print %myhash; return ( %myhash ); } This works fine from testing. -----Original Message----- From: Flyzone [mailto:[EMAIL PROTECTED] Sent: 28 April 2008 18:06 To: beginners@perl.org Subject: hash return from a sub How can i return a copy of the hash? (The hash is build correct, but return alsways null) Here a sample of my code: sub mysub { while (.....) { var1 = ....; var2 = ....; $myhash{$var1} = $var2; } print %myhash; # all ok until here return ( %myhash ); } %test=mysub(); print %test; # wrong, don't print nothing, neither error; I would like to return a copy of the hash to a new variable, not a reference. Thanks in advance. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ This e-mail is from the PA Group. For more information, see www.thepagroup.com. This e-mail may contain confidential information. Only the addressee is permitted to read, copy, distribute or otherwise use this email or any attachments. If you have received it in error, please contact the sender immediately. Any opinion expressed in this e-mail is personal to the sender and may not reflect the opinion of the PA Group. Any e-mail reply to this address may be subject to interception or monitoring for operational reasons or for lawful business practices. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/