Thanks for reply. The question is easily solvable if
it is in the same file as the perl script. You can use
single quotes or backslash to modify the string. 

But as I stated in the message, the "$1.12" was in a
text file along with other things, say you have a
sentence like this in a file: Apple $1.12. You can't
modify the file itself. So it's hard to utilize "\" or
use single quotes because you have to first read the
sentence from a file.

Jason

--- Paul Johnson <[EMAIL PROTECTED]> wrote:

> On Mon, May 08, 2006 at 08:07:56AM -0700, Xuning
> Wang wrote:
> 
> > Hi:
> > 
> > I have a question about replacing $ sign when it
> is
> > before a digit. For example:
> > 
> > $str = "$1.12";
> > 
> > I want to extact the dollar amount 1.12 from $str.
> > 
> > If I do this:
> > $str =~ s/\$//;
> > 
> > $str then become .12. The "$1" in "$1.12" is
> > interpreted first before substitution is applied.
> How
> > do I prevent this?  I can't use this:
> > $str ='$1.12'   because the $1.12 is read from a
> file.
> > 
> > Does anyone have a suggestion? 
> 
> Something else is going on, but I can't say exactly
> where.
> 
>   $ echo '$1.12' | perl -ple 's/\$//'
>   1.12
> 
> Perhaps you have some other interpolation going on
> where you don't need
> it?
> 
> -- 
> Paul Johnson - [EMAIL PROTECTED]
> http://www.pjcj.net
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to