The only explanation I see missing here is how you might build any of these data structures and how to access the data you put into it.
# Declare an array and print out two elements my (@a) = qw( foo bar baz buz ); print join(", ", $a[0], $a[2]), "\n"; # Declare a reference to an anonymous hash and print # out some data from it my ($b) = { 'foo' => 'bar', 'baz' => 'baz' }; print join(", ", $b->{'foo'}, $$b{'baz'}), "\n"; # The following statement is quite odd. my (@c) = [ 'foo', 'bar', 'baz', 'buz' ]; # Perhaps you meant the following: my ($c) = [ 'foo', 'bar', 'baz', 'buz' ]; print join(", ", $c->[1], $$c[3]), "\n"; # Create a regular hash and print out some data: my (%d) = ( 'foo' => 'bar', 'baz' => 'buz' ); print join(", ", $d{'foo'}, $d{'baz'}), "\n";
Note that in the 2nd and 3rd cases I presented, there are 2 methods of accessing the data within the structure. You can either double the dollar sign ($$b{'baz'} or $$c[3]) or use the dereferencing characters ($b->{'foo'} or $c->[1]).
In reply to Re: data types
by Coruscate
in thread data types
by dave8775
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |