in reply to Re^2: If I Want Backslashes, I'll Ask For Backslashes
in thread If I Want Backslashes, I'll Ask For Backslashes

Not quite what Cheezy said... I understand it this way. If \ is normally ignored, and only\'is special (meaning '), how do you really write \'? That's the only time you must write \\ when you meant \. But, since it exists, you need to use it also to write \\ (as \\\\) etc. Other than that, you don't need to write \ as \\ in a single-quote, but you could.

—John

  • Comment on Re: Re^2: If I Want Backslashes, I'll Ask For Backslashes

Replies are listed 'Best First'.
Re^4: If I Want Backslashes, I'll Ask For Backslashes
by tadman (Prior) on Aug 11, 2001 at 02:59 UTC
    Here's my, possibly skewed, reasoning as to how it should work, at least in one sense:
    $_ = '\\something'; # \\something $_ = 'It\'s a tragedy'; # It's a tragedy $_ = '\\''; # \'
    Of course, the last example would probably strike many a C programmer as being far too bizarre to comprehend.

    This is why I expected the q() operator to behave differently. As it was pointed out, the only reason for \\ is because of the requirement for \', which would imply that if \' were no longer an issue, \\ would cease to be relevant as well.

    Here's what I would expect, and yet this is not the case:
    $_ = q[\\something]; # \\something $_ = q[It's a tragedy]; # It's a tragedy $_ = q[\']; # \'
    Update:
    The last "should" example is parsed as such:
    ',\,\','
    That is to say, that this is really a single quote, followed by a single backslash, followed by the token \', followed by a single quote.
      I don't understand your last "should" example. But I agree that it makes sense that the reason you need to escape would follow the closing delimiter. So in qq/blab/ you would need to escape out any contained / character, but not any ' character.