in reply to Re: How do I disable variable expansion of strings?
in thread How do I disable variable expansion of strings?

Thank you for the suggestion, and it would be a valid one in a different context. It's my fault for not being more specific about what I want to do.

The situation is:
=================
There are a set of commands implemented in Perl which make up a command line interface similar to the Bash prompt. Most of these commands display there output to STDOUT. I am attempting to wrap these commands with analogous subroutines in a Perl module, so that instead of printing to STDOUT, I capture a command's output, process it, and return meaningful values. Such a module is more reusable (and I have need of it).

So you see I have to treat this command line interface as a blackbox, though it is possible, I am not 'permitted' to modify the strings that are spewed out when invoking a certain command.

Finally even though I know about using backslashes and literals I don't know how to make use of them in the above code. Any other suggestions.
  • Comment on Re^2: How do I disable variable expansion of strings?

Replies are listed 'Best First'.
Re^3: How do I disable variable expansion of strings?
by ikegami (Patriarch) on Sep 04, 2007 at 13:54 UTC

    The question I hear:

    I have a function that performs string interpolation. Without modifying the function, I want to prevent it from doing this interpolation.

    Either your question is unclear, or you might as well have asked

    I have a function that performs a loop. Without modifying the function, I want to prevent it from doing this loop.

    However, I'm pretty sure I'm understanding the problem incorrectly. Please provide more info. A minimal *representative* snippet would be ideal. The snippet you've already provided isn't representative of your problem.

Re^3: How do I disable variable expansion of strings?
by SuicideJunkie (Vicar) on Sep 04, 2007 at 13:52 UTC

    As mentioned, if you do not want the interpolation, escape the symbol...

    print "\%dsadada ssadasd\n"; print "\@dsadada sdsadasd\n"; print "\$dsadada sdsadasd\n";

    OR, use single quotes...

    print '%dsadada ssadasd' . "\n"; print '@dsadada sdsadasd' . "\n"; print '$dsadada sdsadasd' . "\n";

    Both of which will print:

    %dsadada ssadasd @dsadada sdsadasd $dsadada sdsadasd

    What exactly do you want it to print instead?