you don't need the '?' in it, but that doesn't matter. i tested both your first regex and the one i have here many times with a dummy file, and it worked perfectly. here's mine:[tt]
while (<FILE>) {
s~^\s*,\s*$~null,~;
print;
}[/tt]
it may be that the problem isn't the regex, but the way you're calling it...
sorry i couldn't help any more. "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
This replaces the comma lines with the value of null, not the string. If you want the string, just put 'null' in the right side. The way you were approaching the pattern match, the '^' and '$' pinned the match to the beginning and end of the file...... not the beginning and end of a line. So, just treat the '\n' as any other character and match it. Like this,
I found out that I need to use the /gm switch.
Don't quite know exactly what the /m is, but I suspect there is a Windows/UNIX linefeed problem. I used UltraEdit, and even saving test file as UNIX format did not work without the /m switch?
I guess you guys must have tried my script out in UNIX/Linux?
/m specifies that the match be done with multi-line behavior. were you reading the file in one line at a time, and checking that against the regex, or did you read in the file as one scalar variable, and then test that? "If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
yes, then use /m. it has to do with how it defines certain things, like "." and "$", specifically whether or not they'll match on a newline. basically, if there's more than one line of text in the pattern to be matched, specifiy /m and and use the regex like usual, and i should work like usual.
"If you think you're too small to make a difference, try spending a night in a closed tent with a mosquito."
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.