<HTML dir=ltr><HEAD>
<META http-equiv=Content-Type content="text/html; charset=unicode">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face="Courier New" color=#000000 size=2>This isn't recursive or general use or anything, but it's what I came up with to uppercase specific things in 16 different use cases in some software I'm working on today... I thought it was pretty clean given the task at hand. Feedback welcome. :)</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>j</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><BR><FONT face="Courier New" size=2>=head2 uppercase_everything</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>RT7835 - Uppercase everything sent to OCIS</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2> $self->uppercase_everything($qualifiers);</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>=cut</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>sub uppercase_everything {<BR> my ($self, $qualifiers) = @_;<BR> foreach my $key (keys %$qualifiers) {<BR> # these two have to remain lower case or OWS pukes<BR> next if ($key =~ /^(primary|preferred)$/);<BR> if (ref($qualifiers->{$key}) eq "ARRAY") {<BR> # Ack. Sometimes an arrayref is handed in.<BR> for (@{$qualifiers->{$key}}) {<BR> if (ref $_ eq "HASH") {<BR> # Ack. Hashref inside the arrayref (e.g. UserDefinedValues)<BR> my $href = $_;<BR> foreach my $key (keys %$href) {<BR> $href->{$key} = uc $href->{$key};<BR> }<BR> } else {<BR> # Simple scalars in our arrayref (e.g. AddressLine)<BR> next unless (defined $_);<BR> tr/a-z/A-Z/;<BR> }<BR> }<BR> } elsif (ref($qualifiers->{$key}) eq "HASH") {<BR> # Are we supposed to uppercase any hashrefs?<BR> } else {<BR> # Simple scalar<BR> $qualifiers->{$key} = uc $qualifiers->{$key};<BR> }<BR> }<BR> #warn Dumper($qualifiers);<BR> return 1;<BR>}</FONT></DIV>
<DIV><FONT face="Courier New"><BR><FONT size=2></FONT></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>$ cat Common.t<BR>use Test::More tests => 8;</FONT></DIV>
<DIV><FONT face="Courier New" size=2># Have to instantiate any of the children to test Common...<BR>use Omni2::Model::MF::OWS::Name;<BR>my $c = Omni2::Model::MF::OWS::Name->new();</FONT></DIV>
<DIV><BR><FONT face="Courier New" size=2># Test uppercase_everything().<BR># 'lower' values should stay lowercase. 'upper's should turn to 'UPPER'<BR>my $in = {<BR> primary => 'lower',<BR> test1 => 'upper',<BR> preferred => 'lower',<BR> test2 => [ 'upper', 'upper'],<BR> test3 => [ { test4 => 'upper', test5 => 'upper' } ]<BR>};<BR>ok($c->uppercase_everything($in), 'uppercase_everything()');<BR>is($in->{primary}, 'lower', 'primary');<BR>is($in->{test1}, 'UPPER', 'test1');<BR>is($in->{preferred}, 'lower', 'preferred');<BR>is($in->{test2}->[0], 'UPPER', 'test2');<BR>is($in->{test2}->[1], 'UPPER', 'test2');<BR>is($in->{test3}->[0]->{test4}, 'UPPER', 'test4');<BR>is($in->{test3}->[0]->{test5}, 'UPPER', 'test5');</FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV><FONT face="Courier New" size=2>$ perl Common.t<BR>1..8<BR>ok 1 - uppercase_everything()<BR>ok 2 - primary<BR>ok 3 - test1<BR>ok 4 - preferred<BR>ok 5 - test2<BR>ok 6 - test2<BR>ok 7 - test4<BR>ok 8 - test5<BR></FONT></DIV>
<DIV><FONT face="Courier New" size=2></FONT> </DIV>
<DIV> </DIV></BODY></HTML>