jm am Montag, 26. Februar 2007 18:54:
Hi
> is there a function, module, script, etc. that converts all uppercase to
> proper mixed case. this particular need is for an address list that is all
> uppercase
This description of what you want to achieve does not correspond to the
example below; you also add '.'s and a space, and 'OK' is still non-mixed
case.
> 1370 W 14TH ST
> ADA,OK
> 74837
>
> i would like to convert it to
>
> 1370 W. 14th St.
> Ada, OK
> 74837
you can try to fiddle around with ucfirst and lc, see:
perldoc -f ucfirst
perldoc -f lc
however, some exceptions are to be handled as well as the format kept...
(therefore the map chain below)
The following does some of the tasks (I did not search google...):
#!/usr/bin/perl
use strict;
use warnings;
my $s="
1370 W 14TH ST
ADA,OK
74837
";
print map ucfirst,
map {$_ eq ',' ? ', ' : $_} # handle special case
map {$_ eq 'OK' ? $_ : lc $_ } # dito, instead of unconditional lc
($s=~/(\w+)(\W+)/g); # not very sophisticated :-)
__END__
1370 W 14th St
Ada, OK
74837
Dani
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/