2

Possible Duplicate:
What's the difference between a hash and hash reference in Perl?

Hi,

Trying to understand the concept of hashes in perl The sample code is given below :

#!/usr/bin/perl
use strict;
use warnings;
my %hash =();
%hash = ();
my $hash_ref = {};
$hash_ref->{dhg} = 'jhfkjd';
print $hash_ref->{dhg} . "\n";
$hash{abc} = 'def';
$hash{key2} = 0;
print "$hash{abc}\n";

I get the output as:

jhfkjd
def

I wanted to know what is the difference between $hash_ref and %hash that I have used, although I know it syntactically.

I am absolutely new to perl. Any help will be valuable .

Thanks & Regards,
Tazim.

Community
  • 1
  • 1
Star123
  • 669
  • 2
  • 8
  • 19

0 Answers0