In any quoted string ("", '', qq{}, q{}, etc.), a double backslash must be interpolated as a single backslash, because a backslash is used to escape the quoting character(s). This makes it possible to get the one character string \ and the two character string \', with '\\\'' and '\\', respectively.
I don't see what's wrong with having '\' mean \ and having '\'."'" or q<\'> mean \'. It's a little more typing, but personally if I was the creator of Perl I would sacrifice the special meaning of backslashes in single-quoted strings for more normality...oh well, I'll have to be content with a source filter or using here-docs. But...
Here-docs are the exception to this. One can always find a terminator, possibly several characters long, that doesn't appear within the string itself. <
This is something I've been thinking about. What if I'm quoting arbitrary user-supplied data in an eval()? I wouldn't want to remove any occurances of the here-doc terminator I was using -- that might upset users whose data contains my terminator. Even if the terminator is a long and rare word, there is still a chance of data/terminator clashing -- disallowing the terminator in the data seems very cargo-cult and wrong to me.
I guess the best here-doc terminator in this case would be a randomly-generated one...if only Perl had a qb// operator to quote an arbitrary number of bytes. (__DATA__ doesn't do what I want, since it is only one section. And if I want multiple sections, I need separators. The same exact problem all over again. Oh wait -- I could just store the number of bytes inside each section of the DATA. But then I have an evil arbitrary limit on how much data the user can supply. Unless I use BER encoded integers. Too much work for me.)
In reply to Re: Re: Re: Re: Re: DOS directory naming in PERL?
by Anonymous Monk
in thread DOS directory naming in PERL?
by phathead22
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |