Is that what you want ?

 sub maskIt()
{ my ($char) = shift ; my $ret = "";
 $ret = '_M_' if ($char eq "M") ;
 $ret = '_N_' if ($char eq "N") ;
 $ret = '_O_' if ($char eq "O") ;
 $ret = '_P_' if ($char eq "P") ;
    # Somthing like that, use your way to
    # mask them.....
 return $ret;
}

$string = '{N}EVER G{O}ES {M}AD, {P}LEASE!!!';
$string =~ s/\{(.)\}/&maskIt($1)/eg;
print $string;

Rgds,
Connie


----- Original Message -----
From: "David Carpenter" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 09, 2002 11:14 AM
Subject: a real beginner's question, pt. 2


> Thanks to all those who responded to my original post.  I posted the
> clarifcation below as a reply to the original thread, but I think it was
> lost in the shuffle.
>
> I think I failed to make something clear. What I need is to selectively
> replace only
> certain characters when they appear in a string within brackets. I don't
> need to transform the string as a whole. So if I
> have:
>
> Don't Match the capital M unless {the M is inside brackets} then Match it
>
> I need to be able to change the M inside the brackets in such a way that
the
> entire line is output, but with, in this case, the single change that the
> one M within the brackets has been changed to another character, say an X,
> so that the line would now read:
>
> Don't Match the capital M unless {the X is inside brackets} then Match it
>
> I need to process a very large file (c. 20MB) in this way, and there are
> about a dozen
> different single characters what would have to be systematically changed
to
> an alternative character.  Actually, what I want to do is change the M,
for
> instance, to the Unicode character U+1E43.  I've been able to apply these
> changes to the file as a whole, but don't know how to apply them only to
> certain characters that appear in text within brackets.
>
> I was assuming (wrongly?) that I would have to set up some kind of loop to
> run through each string within brackets to test for the M (and a number of
> other characters) and change it to the U+1E43 (an a number of other
Unicode
> characters) if found.  Can I do all this just using regular expressions
with
> s/// or tr///?
>
> I hope this is more clear.  Thanks again to everyone who has offered help.
> I'm learning a lot about regular expressions!  (or at least I'm trying
to!)
>
> David
>
>
>
>
> --
> 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