playing with hashes
This commit is contained in:
parent
afe4b10808
commit
c4eaadf848
31
cli/hash_variables.pl
Normal file
31
cli/hash_variables.pl
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Data::Dumper;
|
||||||
|
|
||||||
|
|
||||||
|
my %petsounds = (
|
||||||
|
"cat" => "meow",
|
||||||
|
"dog" => "woof",
|
||||||
|
"snake" => "hiss"
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
print "The cat goes " . $petsounds{"cat"} . ".\n";
|
||||||
|
|
||||||
|
|
||||||
|
$petsounds{"mouse"} = "squeak!";
|
||||||
|
$petsounds{"dog"} = "arf!";
|
||||||
|
|
||||||
|
|
||||||
|
delete($petsounds{"cat"});
|
||||||
|
|
||||||
|
|
||||||
|
print "The mouse goes " . $petsounds{"mouse"} . ".\n";
|
||||||
|
|
||||||
|
|
||||||
|
print Dumper(\%petsounds) . "\n";
|
||||||
|
|
||||||
|
|
||||||
|
1;
|
||||||
|
__END__
|
Loading…
Reference in New Issue
Block a user