6

In Uninitialized Value $` in Perl, I want to format as code several Perl variables.

  • If I have one $`, there isn't a problem because the paragraph doesn't have another backtick.
  • If I double up the back ticks, ``$```, there's a problem because the one I want to quote is next to the terminating ones.
  • I don't see that escaping it works, `$``.
  • The problem is that in the paragraph I want other code formatting, so ``$```, which didn't work before, does new things when more backticks show up, like $'

I looked at How can the backtick character ` be included in code?, but that doesn't have an example of the back tick at the end of the code. That advice works if this has a ` in the middle.

I saw Syntax highlighter doesn't handle unpaired backticks, but that's about the big code sections and I'm not having a problem with syntax highlighting.

I also tried HTML tags around the variable, and I put this one at the end so it doesn't mess up everything after it:

  • I can't use HTML tags because the backtick in the variable name starts formatting things when there are later back ticks: $</code> and$&`.

I could put HTML tags around every code bit in the paragraph, but that's annoying.

Maybe this is another reason no one should use $` in Perl. :)

7

The relevant piece is in there if you look close – you just need to add some spaces around your delimiting backticks:

`` $` ``

…becomes $`, the operator you were looking for.

  • Ah, I thought I had tried that too and if I had put it in the list of things in the question would have probably seen that it works. – brian d foy Dec 22 '13 at 16:06
  • As an aside: in comments one would need escaping, @briandfoy: `$\`` for $`. (Only in cases where the code starts and/or ends with a backtick.) – Arjan Dec 22 '13 at 18:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .