August 9th, 2000, 05:06 AM
how can I do this:
$inVar = "this is a string with both " and ' in it which will probably confuses the perl engine";
I could have added slashes by hand.. but the above string is 2000 lines long in my program..
I tried using quotemeta but it didn't work either...
no.. I don't want to store it in a file.. and then do it..
I want to be able to do this within the same file...
how can it be done?
August 9th, 2000, 07:23 AM
$inVar = qq/this is a string with both " and ' in it which will probably confuses the perl engine/;
If you have / characters occuring in your string, use some other delimiter (e.g ~ or !) -- basically, just pick some non-whitespace, non-alphanumeric character that doesn't occur in your string. If there is no such character, then you'll have to escape any characters that match your delimiter (i.e. if you use " as a delimiter you must replace all occurences of " in the string with ", or if you use / you'd have to replace it with /).
One note is that if you're not interpolating variables in that string, you should use single quotes or the q// operator, as that doesn't attempt to do any variable interpolation and so runs a lot faster. If you don't entirely understand what I'm talking about, run:
and go to the section entitled:
Quote and Quote-like Operators