s///x
- From: "Dr.Ruud" <rvtol+news@xxxxxxxxxxxx>
- Date: Wed, 2 Nov 2005 13:31:43 +0100
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."
.
- Follow-Ups:
- Prev by Date: Re: passing data
- Next by Date: Re: perl with Active Directory
- Previous by thread: perl with Active Directory
- Next by thread: Re: s///x
- Index(es):
Relevant Pages
|