Well, I have no idea why it does what it does, but I can tell you how to
make it work:
s¶3(456)7¶¶$1¶x;
s§3(456)7§§$1§x;

For whatever reason, Perl is treating those character as an 'opening'
delimiter[0], so that when you write s¶3(456)7¶$1¶;, you are telling Perl
that the regex part is delimited by '¶'s, but the substitution part is
delimited by '$'s (think of something like s{}//;).

Hopefully someone here will be able to enlighten us both further.

Brian.

[0]
http://perldoc.perl.org/perlop.html#Gory-details-of-parsing-quoted-constructs

On Sun, Dec 5, 2010 at 6:33 PM, Jonathan Pool <p...@utilika.org> wrote:

> The perlop document under "s/PATTERN/REPLACEMENT/msixpogce" says "Any
> non-whitespace delimiter may replace the slashes."s
>
> I take this to mean that any non-whitespace character may be used instead
> of a slash.
>
> However, I am finding that some non-whitespace characters cause errors. For
> example, using a "¶" or "§" character instead of a slash causes an error,
> such as "Bareword found where operator expected" or "Number found where
> operator expected". When I use a "/", "#", or ",", I get no error. Here is a
> script that demonstrates this problem:
>
> #!/usr/bin/perl -w
> use warnings 'FATAL', 'all';
> use strict;
> use utf8;
> my $string = '123456789';
> print "The original string is $string\n";
> $string =~ s§3(456)7§$1§;
> print "The amended string is $string\n";
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>

Reply via email to