in reply to Incredibly stupid substitution question :(

Well, if this is driving you crazy, you're not alone. I tried your code on my system (ActiveState Perl 5.12) and used Data::Dumper. When I print the variable (print "$text\n";), it appears just as you want it. When I do print Dumper($text);, it has an extra \ in it just like you're seeing.

As for why Data::Dumper is not matching the print statement, I'm stumped.

Replies are listed 'Best First'.
Re^2: Incredibly stupid substitution question :(
by CountZero (Bishop) on Aug 11, 2010 at 13:49 UTC
    As for why Data::Dumper is not matching the print statement, I'm stumped.

    Because the output of Data::Dumper can be evaled into the original string, hence the "escaping" of the backslashes.

    This means that the original string only had single backslashes, otherwise Data::Dumper would have shown 4 backslashes in a row!

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      Cool! Thanks for the explanation. Learned something new.