in reply to Regex question

$points = s//(points)+.,/;

Your regular expression is empty which means it will match at the first character boundary which is the beginning of the string and will substitute that with the text string "(points)+.," so if the current line in $_ contains qq[levels: "PKLMOKNLP",\n] after the substitution it will contain qq[(points)+.,levels: "PKLMOKNLP",\n].

The substitution operator always returns either true (1) if the substitution succeeded or false ('') if the substitution failed and in your case the substitution will always succeed so $points will always be assigned the value 1.

Replies are listed 'Best First'.
Re^2: Regex question
by toolic (Bishop) on Jul 04, 2008 at 15:32 UTC
    The substitution operator always returns either true (1) if the substitution succeeded
    Just to elaborate, from perlop:
    returns the number of substitutions made
    So, as in the case of the OP, s/// will return 1 if a substitution is made, but s///g can return more than 1 if many substitutions are made.