[Linux-disciples] perl question: why do modules return a reference to a hash and not a hash?

Stephen R Laniel steve at laniels.org
Thu Dec 22 13:39:07 EST 2005


On Thu, Dec 22, 2005 at 01:33:55PM -0500, Adam Rosi-Kessel wrote:
> If someOtherFunc() returns a hash, however, then it will be a unitary item,
> regardless of whether it is a hash, or a reference to hash.
> 
> No?

I don't believe so, no. A hash is just an array. That's why
you can do

my %newHash = ();

just as you could do

my @newArray = ();

For some kind of proof that a hash is an array, you can run

	#!/usr/bin/perl
	use strict;
	use warnings;
	
	my %newArray = (
		'a'	=>	1,
		'b'	=>	2,
		'c'	=>	3
	);
	
	print join "\n", %newArray;

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20051222/4a851724/attachment.pgp


More information about the Linux-disciples mailing list