Ah, my apologies.

To apply the translation explicitly to a variable, do:

    $var =~ tr/a-zA-Z/A-Za-z/;

but if no variable is specified, then $_ is used implicitly. Also, if you
specify the name of the input file on the command line you can simply write:

    while (<>)
    {
        tr/a-zA-Z/A-Za-z/;
        print;
    }

HTH,

Rob

----- Original Message -----
From: "Prasad K M" <[EMAIL PROTECTED]>
To: "Rob Dixon" <[EMAIL PROTECTED]>
Sent: Thursday, January 02, 2003 10:04 AM
Subject: Re: toggle the case


> 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: "Rob Dixon" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, January 02, 2003 3:21 PM
> Subject: Re: toggle the case
>
>
> > Hmm. Sometimes there's only one way to do it :)
> >
> > /R
> >
> >
> > "John W. Krahn" <[EMAIL PROTECTED]> wrote in message
> > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > > 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