s///x



I was trying the s///x syntax and got unexpected results.
Somebody cares to explain?

Simplified example:

#!/usr/bin/perl

use warnings;
use strict;

local ($,, $\) = ("\t", "\n");
my $x;

$_ = "abc 123 def 123 ghi";

$x = s/ # Replace
1 # ONE
2 # TWO
3 # THREE
/ # by
4 # FOUR
5 # FIVE
6 # SIX
/gsx; # global, single line, extended format

print 'Made', $x, 'replacements.';
print;


This printed:

Made 2 replacements.
abc # by
4 # FOUR
5 # FIVE
6 # SIX
def # by
4 # FOUR
5 # FIVE
6 # SIX
ghi

I expected: abc 456 def 456 ghi

--
Affijn, Ruud & perl, v5.8.6 built for i386-freebsd-64int

"Gewoon is een tijger."
.



Relevant Pages