Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Hash reference in Perl

Answer:

Hash reference is something like a pointer to a hash data structure in Perl

Example:

my %hash = (
        "a" => "1",
        "b" => "2",
);

my $hash_ref = \%hash;

$hash{"a"} = "A";

print $hash_ref->{"a"}; # print out "A" as change in  %hash  also reflected in its reference

  1. Array reference in Perl
  2. Pass hash as reference in Perl
  3. A simple hash in Perl
  4. How to find out whether reference is pointing to a scalar, array or hash in Perl?
  5. Counting the number of pair(s) in Perl’s hash

One Response to “Hash reference in Perl”

  1. Stumbled throughout from google, and read your excellent post

Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>