Rob Dixon wrote:
> 
> Once more my apologies. I was in a rush this morning and shouldn't have
> posted in haste. Thanks to John I now understand the question :-/ FWIW my
> solution is the same as John's but I put a subroutine around the tr//:
> 
>     sub SwapUL { (my $s = shift) =~ tr/A-Za-z/a-zA-Z/; $s; };
> 
>     my $text = 'aaa MIXED bbb MiXeD ccc mixED ddd mixed';
>     $text =~ s/\b(mixed)\b/SwapUL($1)/ieg;
> 
>     print "$text\n";
> 
> output:
> 
>     aaa mixed bbb mIxEd ccc MIXed ddd MIXED

Or you could use a hash.  :-)

$ perl -le'use locale;
$_ = "This Is A Mixed Case Sentence. ÇÈÝøáêëì";

$convert{lc()} = uc and $convert{uc()} = lc for grep /[[:alpha:]]/, map chr, 0 .. 255;

s{(\w+)}{($a=$1)=~s[(.)][$convert{$1}]g;$a}ieg;
print'
tHIS iS a mIXED cASE sENTENCE. çèýØÁÊËÌ



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to