I sink the are copied in boat places for the first teste this code
use Data::Dumper; sub PassHash { my (%new_hash) = @_; $new_hash{a} = 3; } my %hash = (a=>1, b=>2); PassHash(%hash); print Dumper(\%hash); :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: ::::::::: for the second teste this code use Data::Dumper; my %hash = (a=>1, b=>2); sub CreatHash { return %hash; } sub OtherProc { my %new_hash = CreateHash(); $new_hash{a} = 3; print Dumper(\%hash); } Marcos -----Original Message----- From: Lodewijks, Jeroen [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 29, 2003 4:47 PM To: '[EMAIL PROTECTED]' Subject: quick question on internal data structure Hi all, I have a 2 questions about the internal representation of a hash or array. Consider this piece of code: 1) sub PassHash { my (%hash) = @_; $hash{$some_key} = 'test'; ... } PassHash(%hash); What happens internally? Will the whole contents of the hash be copied in memory? Or is only a reference passed? Will the $some_key element show up after PassHash? Does the same apply to arrays? 2) sub CreatHash { my %hash; ... do something with hash; return %hash; } sub OtherProc { my %new_hash = CreateHash(); .... } What happens internally? Will the whole contents of the hash be copied in memory to %new_hash? Or is only a reference passed? When is %hash garbage collected and when is %new_hash? Does the same apply to arrays? Thank you for you answers in advance. I need this information to optimise memory requirements for my program. Jeroen -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]