Perl 6 Hashes
Fetching data from a hash
Associative Arrays (Hashes)A hash (also called associative array) is a set of key,value pairs where the keys are unique strings and the values can have any, err value. Hashes always start with a % (percentage) sign.examples/hash/create_hash.p6 #!/usr/bin/perl6
use v6;
my %user_a = "fname", "Foo", "lname", "Bar";
my %user_b =
"fname" => "Foo",
"lname" => "Bar",
;
say %user_a{"fname"};
%user_a{"email"} = "foo@bar.com";
say %user_a{"email"};
say %user_b<lname>;
Copyright 2006, 2007, 2008, 2009, 2010 Gabor Szabo http://szabgab.com/ Index | TOC |
Follow me: