That's quite easy. Just ask Perl to tell you what it sees:
Q:\>perl -w -MO=Deparse -e "s;;new;;old;;g" Unquoted string "old" may clash with future reserved word at -e line 1 +. Unquoted string "g" may clash with future reserved word at -e line 1. Useless use of a constant in void context at -e line 1. Useless use of a constant in void context at -e line 1. BEGIN { $^W = 1; } s//new/; '???'; '???'; -e syntax OK
So basically, your program is equivalent to $one =~ s//new/;, which replaces the first empty place in the string $one with new, which is what you see.
Also, this shows again why running with warnings enabled reveals many problematic spots in the code.
In reply to Re: search and replace using regular expression
by Corion
in thread search and replace using regular expression
by jesuashok
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |