in reply to Incredibly stupid substitution question :(

One regex-less way to do this is to split around the (.) into an array and join the elements back;
use strict; use warnings; my $string = "Kev.has.a.stupid.perl.question"; my @array = split /\./, $string; my $fixed = join('\.',@array); print $fixed;
Though, your regex $text =~ s/\./\\./g; seems to can work fine!.

update: added links and a bit of details


Excellence is an Endeavor of Persistence. A Year-Old Monk :D .

Replies are listed 'Best First'.
Re^2: Incredibly stupid substitution question :(
by JavaFan (Canon) on Aug 11, 2010 at 09:03 UTC
    One regex-less way to do this is to split
    Uhm, you do know split, don't you? And you do know the type of its first argument, don't you?

    Indeed, you do. Your "regexp-less" way uses the same regexp as you're trying to avoid. All you did was to move the regexp from s/// to split. You "regexp-less" way does not use less regexpes, or even a simpler one.

Re^2: Incredibly stupid substitution question :(
by wwe (Friar) on Aug 11, 2010 at 07:50 UTC
    the original regex didn't worked on my system too. I'm using Strawberry Perl 5.10 on WinXP.