- or download this
# Snippet 1 - a stepping stone
use strict;
...
# Heck, Alice, Bob, Charlie -- they're all pretty cool!
print Dumper \%phonebook;
- or download this
Bob's digits are 555 9876
...
'Alice' => '555 1234',
'Charlie' => '555 2580'
};
- or download this
# Snippet 2a - another stepping stone
use strict;
...
# Gimme all their digits!
print Dumper \%phonebook;
- or download this
Alice's home number is 555 1234
Charlie's mobile number is 555 2468
...
'home' => '555 3456'
}
};
- or download this
# Snippet 2b - append to snippet 2a
for (1..3) {
printf "Alice and Bob: %s and %s\n", \%alice, {%bob}
}
- or download this
Alice and Bob: HASH(0x328358) and HASH(0x380138)
Alice and Bob: HASH(0x328358) and HASH(0x3801e0)
Alice and Bob: HASH(0x328358) and HASH(0x380168)
- or download this
# Snippet 2c -- append after 2b
delete $alice{home}; # Delete Alice's home number **from he
+r original hash**
...
delete $phonebook{Charlie}; # Let's not clutter the output
print Dumper \%phonebook;
- or download this
$VAR1 = {
'Bob' => {
...
'mobile' => '555 2580'
}
};
- or download this
# Snippet 3 - your answer?
use strict;
...
}
}
print Dumper \%phonebook;
- or download this
$VAR1 = {
'bar-Bob' => {
...
]
}
};