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

Cheers all,

Rob





"Prasad K M" <[EMAIL PROTECTED]> wrote in message
018501c2b249$e97b64d0$[EMAIL PROTECTED]">news:018501c2b249$e97b64d0$[EMAIL PROTECTED]...
> thanks...
> i am trying to search a pattern and replace that pattern with its toggled
> version...
>
> eg: s/pattern/<toggled>/g
>
> the prob is i can't embed 'tr/a-zA-Z/A-Za-z/' in the <toggled> part or
> atleast i dont know how to do it !!
>
> --prasad
>
>
> ----- Original Message -----
> From: "John W. Krahn" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, January 02, 2003 2:21 PM
> Subject: Re: toggle the case
>
>
> > Prasad K M wrote:
> > >
> > > Hi,
> >
> > Hello,
> >
> > > I want to read a file and print all the text , but reverse the case.
> > >
> > > So all small will become CAPS and CAPS will be small .
> > >
> > > The problem is toggling the case. Any idea as how to accomplish it ?
> >
> > $ perl -le'$_ = "This Is A Mixed Case Sentence."; tr/a-zA-Z/A-Za-z/;
> > 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]
>



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

Reply via email to