[Perl] printing a hash

Offer Kaye oferk at oren.co.il
Mon Jun 24 06:49:09 PDT 2002


The following file:

************************************************
#!/usr/local/bin/perl -w
use strict;


my %arr_hash1 = ('1' , 'do' , '2' , 're' , '3' , 'me' ,
		 '4' , 'fa' , '5' , 'so' , '6' , 'la' ,
		 '7' , 'se' , '8' , 'do');

print "%arr_hash1\n";
print %arr_hash1, "\n";
************************************************

Gives when run:
%arr_hash1
1do2re3me4fa5so6la7se8do

i.e. the second "print" worked as I expected, the first did not. How come?

BTW, obviously this is not how I would REALLY print the contents of a hash,
this is just for a quick look for debug purposes.

10x in advance,
Offer Kaye




More information about the Perl mailing list