Questions about this topic? Sign up to ask in the talk tab.

Perl/Basics/Variables and Data Types/References/Hash

From NetSec
Jump to: navigation, search

A hash reference is a scalar created using the \ operator as follows:

my %user;
$user{'name'}    = "hatter";
$user{'network'} = "";
my $hashref = \%user;

Once you've created a hashref (hash reference) you must use pointers to access a key:

print $user->{'name'} . "\n";
print $user->{'network'} . "\n";