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>


Reply via email to