Camelia
Prev: Hashes (Associative Arrays)

Fetching data from a hash

examples/hash/print_hash.p6
#!/usr/bin/env perl6
use v6;

my %user = 
    "fname" => "Foo", 
    "lname" => "Bar",
    "email" => "foo@bar.com",
;

for %user.keys.sort -> $key {
    say "$key  %user{$key}";
}

Output

examples/hash/print_hash.p6.out
email  foo@bar.com
fname  Foo
lname  Bar

Prev: Hashes (Associative Arrays)

Table of Contents

Comments

In the comments, please wrap your code snippets within <pre> </pre> tags and use spaces for indentation.
comments powered by Disqus

Perl 6 Tricks and Treats newsletter

Register to the free newsletter now, and get updates and news.
Email:
Name: