in reply to Re^2: Remove $
in thread Remove $

I understand the danger. That's why I gave the warning at the end. However, notice the context of the string in which he's interested. It's a filepath, which means that it might not have been input by hand, but by some directory walker. In that case he may not be able to insert a '\' or catch the '$' before it interpolates. In that extreme case, he may choose to change the new-line character, but should only do so temporarily. Of course it's dangerous, but it's the bad-boy solutions that perl allows that make it such a wonderful language to use. Document it well, and be smart about it, and it should work fine.

Replies are listed 'Best First'.
Re^4: Remove $
by ikegami (Patriarch) on Aug 27, 2007 at 17:33 UTC

    Not so! Interpolation only occurs in string literals, and string literals only exist in source code. Your directory walker would deal with strings, not string literals.

    Either he's dealing with a string literal where local $/ would be the wrong solution, or he's dealing with a string (where local $/ wouldn't help.

      Well I shall yield to your rank and experience. I'm just a mechanical engineer. I guess unorthodox solutions are common in my field, but may be less appropriate in the world of programming. A thousand apologies.
        Well I shall yield to your rank and experience. I'm just a mechanical engineer. I guess unorthodox solutions are common in my field, but may be less appropriate in the world of programming.

        That's surely not what you meant, but are you aware that reading your claim could scare me next time I enter a car? :-)