in reply to pass by reference
The problem is you haven't defined what you want to happen if an uppercase key by the same name already exists.#!/usr/bin/perl -w use strict; my %horoscopes = ( 'homer' => 'pisces', 'marge' => 'sagitarius', 'bart' => 'cancer', 'libra' => 'libra' ); capitalize(\%horoscopes); sub capitalize { my $hash = shift; for my $key (keys %{$hash}) { $hash->{uc $key} = $hash->{$key}; delete $hash->{$key}; } }
Cheers - L~R
|
|---|