in reply to Re^2: Extracting money from a double quoted string
in thread Extracting money from a double quoted string

The code you posted already works for me, with the simple change of double to single quotes:

#!/usr/local/bin/perl $string='Price is $9.99 on our website'; ($money) = $string =~ m/is\s\$([0-9]{1,2}\.[0-9]{2})\son/g; print $money; __END__ 9.99

You can help us help you better by posting a short, self-contained program that we can use to reproduce your problem.

Replies are listed 'Best First'.
Re^4: Extracting money from a double quoted string
by sherab (Scribe) on Dec 06, 2014 at 18:59 UTC
    You'll note that I pointed out in my original question that it works with ' '. Thanks

      Then let me repeat what I gave as an answer in my first reply to you:

      As an alternative, you could quote the dollar sign, so that Perl knows you don't mean the variable $9:
      my $string= "Price is \$9.99 on our website";

      What part of that answer does not apply to your problem?

      Is your question why $string does not contain the value 9.99 when you use double quotes? Is your question about the difference between double and single quotes in Perl? Is your question about what the variable $9 contains?