EchoAngel has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks In one variable i have the following :
values ( \ "0.017874, 0.021970, 0.030369, 0.046419, 0.079837, 0.149591, + 0.293028", \ "0.017943, 0.022035, 0.030418, 0.046421, 0.079824, 0.149598, + 0.293026", \ "0.018809, 0.022714, 0.030916, 0.046686, 0.079949, 0.149627, + 0.293054", \ "0.022414, 0.026140, 0.033679, 0.048570, 0.080821, 0.149893, + 0.292930", \ "0.027887, 0.031599, 0.038779, 0.053037, 0.084057, 0.151348, + 0.293312", \ "0.036945, 0.040592, 0.047732, 0.061178, 0.090290, 0.155268, + 0.295424", \ "0.051912, 0.055826, 0.063219, 0.076534, 0.104252, 0.165988, + 0.302410");
I tried $line_data =~ s/\bvalues\b\s*(.*)\;//; but nothing is changing. Any Ideas?

Replies are listed 'Best First'.
Re: Problems With Pattern Matching
by ikegami (Patriarch) on Nov 16, 2004 at 16:07 UTC

    You want to use s///s instead of just s///, since . doesn't match newlines without the /s:
    s/\bvalues\b\s*(.*)\;//s

    The \ is unnecessary in \;:
    s/\bvalues\b\s*(.*);//s

    The regexp might match more than you want it to match, unless you change the .* to .*?:
    s/\bvalues\b\s*(.*?);//s

    Are you trying to capture (set $1) with the parens, or trying to match the parens in $line_data? If the latter, than you need to escape the parens in the regexp with a \:
    s/\bvalues\b\s*\(.*?\);//s
    Doing so also makes the second \b redundant, so you end up with:
    s/\bvalues\s*\(.*?\);//s;

Re: Problems With Pattern Matching
by Jaap (Curate) on Nov 16, 2004 at 16:03 UTC
    What are you trying to achieve? Does $line_data =~ s/values\s//; do something? Maybe you can build it up from there.