in reply to search and replace using regular expression

As is often the case, adding "use strict" and "use warnings" gives a clue:

Bareword "old" not allowed while "strict subs" in use at ./re line 7. Bareword "g" not allowed while "strict subs" in use at ./re line 7.

B::Deparse is another useful tool.

$ perl -MO=Deparse re my $one = 'TestnewTest'; $one =~ s//new/; '???'; '???'; print "$one\n"; re syntax OK

The delimiters for the substitution operator can only be single characters[1]. Your code is therefore being interpreted as:

$one =~ s//new/; 'old';; 'g';

So the first empty string Perl finds (at the start of $one) is changed to "new".

[1] I feel sure that someone will be along shortly to point out exceptions to that rule :-)

--
<http://dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg