CharlesClarkson has asked for the wisdom of the Perl Monks concerning the following question:
I am attepting to pass an optional anonymous hash as the first argument to a function. I allow any case for the keys and values. I then convert the hash in the hash reference to all lowercase. I have isolated the method I am using to this small script. My question is: Is there a way to convert the keys and values of a hash to all lowercase without using a temporary hash? (I realize this will change the original hash.)
#!/usr/bin/perl use strict; use diagnostics; use Data::Dumper; my $hash_ref = { Extension => '.txt', Content => 'text', Directory => 'c:/' }; print Dumper $hash_ref; my %lc_hash; $lc_hash{lc $_[0]} = lc $_[1] while @_ = each %$hash_ref; $hash_ref = \%lc_hash; print Dumper $hash_ref; __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How do I convert entire hash to lowercase?
by japhy (Canon) on Nov 18, 2001 at 11:50 UTC | |
by data64 (Chaplain) on Nov 18, 2001 at 21:49 UTC | |
by japhy (Canon) on Nov 18, 2001 at 23:20 UTC | |
|
Re: How do I convert entire hash to lowercase?
by chipmunk (Parson) on Nov 18, 2001 at 22:01 UTC | |
by chromatic (Archbishop) on Nov 19, 2001 at 00:57 UTC | |
by japhy (Canon) on Nov 19, 2001 at 01:00 UTC | |
|
Re: How do I convert entire hash to lowercase?
by Zaxo (Archbishop) on Nov 18, 2001 at 12:40 UTC |