Home : General : Perl Programming :

General: Perl Programming: Re: [Lacan] OOPerl: Edit Log

Here is the list of edits for this post
Re: [Lacan] OOPerl
>>
Can someone explain why this makes a new hash and returns a reference to it:

sub hashem { +{ @_ } }
<<

A hash is just an associative array, ie the following will work as a hash but may look like an array to you:

my %hash = ( a, 1, b, 1, c ,1 );

$hash{a} prints 1 as does $hash{b} and $hash{c};

The { } references @_ which is essentially the same as

%hash = \%hash;

The + sign forces an anonymous hash contructor.

Last edited by:

Paul: Aug 23, 2002, 7:20 AM

Edit Log: