X-Git-Url: https://feistymeow.org/gitweb/?a=blobdiff_plain;f=infobase%2Fexamples%2Fperlisms%2Fexample_perl_array_and_hash.pl;fp=infobase%2Fexamples%2Fperlisms%2Fexample_perl_array_and_hash.pl;h=5c75760adbe9803cc419e29e12380dab7e7ba399;hb=5af202498131eb5eed099b84187e59889303faa8;hp=0000000000000000000000000000000000000000;hpb=a4d12589f1cd01826814842cde0b3eac95890bc9;p=feisty_meow.git diff --git a/infobase/examples/perlisms/example_perl_array_and_hash.pl b/infobase/examples/perlisms/example_perl_array_and_hash.pl new file mode 100644 index 00000000..5c75760a --- /dev/null +++ b/infobase/examples/perlisms/example_perl_array_and_hash.pl @@ -0,0 +1,21 @@ + +# define an array. +@fred = ('x', 'y', 'z'); + +# define a hash. +%fred = (x => 'farfle', q => 'nuggy', r => 'bunko'); + +# show the array. +print "\@fred is: @fred\n"; +# show the first element of the array. +print "\$fred[0] is $fred[0]\n"; + +# show the details of the hash. +@fredkeys = keys(%fred); +print "\%fred keys are: @fredkeys\n"; +@fredvals = values(%fred); +print "\%fred values are: @fredvals\n"; +# show the value for the first key we defined in the hash (although that's incidental; +# we don't expect to access things in the hash by their order of addition or even by +# numerical indexes at all. +print "\$fred['x'] is $fred{'x'}\n";