in reply to Incredibly stupid substitution question :(

perl -le '$_=q[Kev.has.a.stupid.perl.question];s/\./\\./g;print' Kev\.has\.a\.stupid\.perl\.question
This works in my system

~suhail

Replies are listed 'Best First'.
Re^2: Incredibly stupid substitution question :(
by viffer (Beadle) on Aug 11, 2010 at 07:26 UTC
    when I do print, yes it does give me that,
    looking through perl debug it gives me
    Kev\\.has\\.a\\.stupid\\.perl\\.question'

    maybe it's just how it shows up in debug. Cheers

      viffer:

      How are you displaying it under the debugger? I'm seeing the expected value (using perl v5.10.1 under cygwin):

      roboticus@Boink:~$ cat 854238.pl my $text = "Kev.has.a.stupid.perl.question"; $text =~ s/\./\\./g; $text .= "."; print $text; roboticus@Boink:~$ perl 854238.pl Kev\.has\.a\.stupid\.perl\.question. roboticus@Boink:~$ perl -d 854238.pl ...snip... main::(854238.pl:1): my $text = "Kev.has.a.stupid.perl.question"; DB<1> b 3 DB<2> r main::(854238.pl:3): $text .= "."; DB<2> p $text Kev\.has\.a\.stupid\.perl\.question DB<3>

      ...roboticus

        using x $text rather than print $text
        ie
        my $text = "Kev.has.a.stupid.perl.question"; DB<1> x $text 0 'Kev.has.a.stupid.perl.question' $text =~ s/\./\\./g; DB<2> x $text 0 'Kev\\.has\\.a\\.stupid\\.perl\\.question'