On Thu, 2 Jan 2003, John W. Krahn wrote:

> Rob Dixon wrote:
> >
> > "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > Prasad K M wrote:
> > > >
> > > > 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.
> >
> > Hmm. Sometimes there's only one way to do it :)
>
> Perl's motto is "There's more than one way to do it"  :-)
>
> $ perl -le'$_ = "This Is A Mixed Case Sentence.";
> s/([[:alpha:]])/$1 eq lc($1)?uc($1):lc($1)/eg; print'
> tHIS iS a mIXED cASE sENTENCE.
>

$ perl -le'$_ = "This Is A Mixed Case Sentence.";
print join"",map{$_=ord;$_+=$_>64 && $_<91 ? 32:$_>96 && $_<123 ? -32:0;chr} split //;'
tHIS iS a mIXED cASE sENTENCE.


George P.


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

Reply via email to