getting changes from cakelampvm
[feisty_meow.git] / infobase / examples / perlisms / example_perl_array_and_hash.pl
1
2 # define an array.
3 @fred = ('x', 'y', 'z');
4
5 # define a hash.
6 %fred = (x => 'farfle', q => 'nuggy', r => 'bunko');
7
8 # show the array.
9 print "\@fred is: @fred\n";
10 # show the first element of the array.
11 print "\$fred[0] is $fred[0]\n";
12
13 # show the details of the hash.
14 @fredkeys = keys(%fred);
15 print "\%fred keys are: @fredkeys\n";
16 @fredvals = values(%fred);
17 print "\%fred values are: @fredvals\n";
18 # show the value for the first key we defined in the hash (although that's incidental;
19 # we don't expect to access things in the hash by their order of addition or even by
20 # numerical indexes at all.
21 print "\$fred['x'] is $fred{'x'}\n";