What perl data structure is this?

my $struct = { 1 => "Image", 2 => "Audio", 3 => "Video" };

What data structure in perl does above statement represent ? is it a Hash or array ?

Thanks !

Answers


$struct is hash reference (or hashref) - scalar variable that is pointing to hash (similar to C pointer, but not quite it).

To create hash, use:

my %hash = ( key1 => "value1", ... );

To create hashref, use braces:

my $hashref = { key1 => "value1", ... };

In this example, you can also create hashref using backslash operator\ (similar to & operator in C):

my $hashref = \%hash;

Need Your Help

Objective-C Astronomy Library

objective-c astronomy

I need to do some moonrise azimuth and time calculations. Can anyone recommend a good astronomy library, preferably in Objective-C?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.