What are best practices for working with hashes (%)?

perl, hashes, best practices, programming, coding, data structures
Best practices for working with hashes in Perl, including tips for managing data structures efficiently and effectively.
# Example of a Perl hash
my %hash = (
    name => 'John Doe',
    age  => 30,
    city => 'New York',
);

# Accessing hash values
print "Name: $hash{name}\n";  # Output: Name: John Doe
print "Age: $hash{age}\n";    # Output: Age: 30
print "City: $hash{city}\n";  # Output: City: New York

# Adding a new key-value pair
$hash{country} = 'USA';

# Iterating over the hash
foreach my $key (keys %hash) {
    print "$key: $hash{$key}\n";
}

perl hashes best practices programming coding data structures