in reply to Re: Remove $
in thread Remove $

But there is a way... backslashing the $:
$text = "db1\$/SQL/GEMINI/StoredProcs/pboValidateClientRefNo_ClientID

If he can change the code to add { local $/ = '/'; ... }, he can change the code to add $.

I consider your advice very dangerous.

Replies are listed 'Best First'.
Re^3: Remove $
by dogz007 (Scribe) on Aug 27, 2007 at 17:22 UTC
    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.

      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.