### Re: Hashes... Light switch isn't coming on

by muba (Priest)
 on Dec 12, 2012 at 18:11 UTC ( #1008548=note: print w/replies, xml ) Need Help??

```# Snippet 1 - a stepping stone
use strict;
...

# Heck, Alice, Bob, Charlie -- they're all pretty cool!
print Dumper \%phonebook;
```
```Bob's digits are 555 9876

...
'Alice' => '555 1234',
'Charlie' => '555 2580'
};
```
```# Snippet 2a - another stepping stone
use strict;
...

# Gimme all their digits!
print Dumper \%phonebook;
```
```Alice's home number is 555 1234
Charlie's mobile number is 555 2468
...
'home' => '555 3456'
}
};
```
```# Snippet 2b - append to snippet 2a
for (1..3) {
printf "Alice and Bob: %s and %s\n", \%alice, {%bob}
}
```
```Alice and Bob: HASH(0x328358) and HASH(0x380138)
Alice and Bob: HASH(0x328358) and HASH(0x3801e0)
Alice and Bob: HASH(0x328358) and HASH(0x380168)
```
```# 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;
```
```\$VAR1 = {
'Bob' => {
...
'mobile' => '555 2580'
}
};
```
```# Snippet 3 - your answer?
use strict;
...
}
}
print Dumper \%phonebook;
```
```\$VAR1 = {
'bar-Bob' => {
...
]
}
};
```

Create A New User
Node Status?
node history
Node Type: note [id://1008548]
help
Chatterbox?
and snow settles gently...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2018-04-24 22:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (88 votes). Check out past polls.

Notices?