in reply to Double double quoting - nested macro calls

If you think you have a solution, can you give a concrete example of it in operation – some short, standalone, runnable code? From your description, I cannot envision what your solution might be.

Approaching from another angle, what you describe sounds a bit like a text templating system, so maybe take a look at Text::Template.

  • Comment on Re: Double double quoting - nested macro calls

Replies are listed 'Best First'.
Re^2: Double double quoting - nested macro calls
by kenm (Acolyte) on Apr 22, 2011 at 22:22 UTC

    Thanks for the reply guys... haven't got code examples to hand I'm afraid. Something I was trying to get sorted in work today and finished for the weekend.

    Basically a hierarchy of macros:
    1) run a command on a remote machine & validate output etc.
    2) Under the covers this calls another macro that rsh's and calls a small little standalone perl program to do what we want on the remote machine.
    3) This standalone perl program then adds a string to a file.

    So at each level a set of double quotes in essence is removed... so I suspect I need to pad out with "extras" to allow for the hierarchy?

    By the time we get to the standalone perl program its essentially getting a

    print This is the test string

    rather than

    print "This is the test string"

      ... By the time we get to the standalone perl program its essentially getting a ...

      I think you misunderstand, see How do I post a question effectively?

      For a recent example of this principal in action see the programs posted in Relative URI, they're small, compile and run, and they reproduce the problem ; they show sample input, desired output, actual (and erroneous) output.

      Hi :)

      I am not a Unix GURU, so some of the usage for rsh that I have below is probably jacked up, but Sounds like this is the scenario to me.

      $string = "This is my string"; my $output = `rsh -l remoteuser host.example.com "perlprog.pl $string" +`;

      With the above code, $string is going to equal This is my string not "This is my string". Therefore when rsh is called as an external application, the resulting command on the remote system is perlprog.pl This is my string instead of the desired perlprog.pl "This is my string"

      Seems like you should be able to add the double quotes to the parameter by escaping them. Similar to the following.

      $string = "This is my string"; my $output = `rsh -l remoteuser host.example.com "perlprog.pl \"$strin +g\""`;