in reply to Change double quote to single quotes

    my($text2) = "test_\1_\2_\3";

In the line above, the backslashes are being interpolated since they are in double quotes. To avoid the interpolation, modify it like:

my($text2) = 'test_\1_\2_\3';  # Single-quotes don't interpolate

or

my($text2) = "test_\\1_\\2_\\3"; # Escaping the backslashes

As for the beginning portion, you might want to use Data::Dumper to verify that $GenEnt is really holding what you think it is. That would be my first step in debugging the problem.

Replies are listed 'Best First'.
Re^2: Change double quote to single quotes
by rookie_monk (Novice) on Sep 02, 2010 at 18:18 UTC
    The 2nd part
    my($text2) = "test_\1_\2_\3";
    is just to test if I could convert from double quoted string to single quoted string. I know how to avoid interpolation, but I dont know how to converted once its interpolated. Thanks for the help. -Paul

      In my opinion, you need to find out where the interpolation is happening and then do something in your code and/or data entry to prevent the interpolation. Otherwise, you're trying to look a string, figure out if anything has been interpolated, find the interpolated characters, and then figure out how to undo/reverse the interpolation. That's a lot of guess work. Perhaps someone has figured out a good method for doing that, but that's above my level and skill knowledge to be able to do.

      I agree with JavaFan in that the interpolation is happening in the code. Meaning that your code either interpolates and then stored the interpolated string into the variable or your code interpolates the variable's content when you use it.

      If you can provide code for the widget (and the 'get' method in particular), perhaps someone can help identify where the interpolation is happening. If the interpolation is happening inside code from a module, then you might need to escape the backslashes (\\) in the data entry, which would interpolate into a single backslash.