On Thu, Dec 05, 2002 at 02:59:32AM -0500, Joseph F. Ryan wrote: > In the first string, perl will take each character in the first string > literally and perform no special processing. However, the value of the > variable $animal is inserted into the second string string in place of > the text $animal. If $animal had had the value "fox", then the second > string would have become "The quick brown fox".
One of these 'in the first string's is surplus to requirements. I'd suggest getting rid of the first one. Getting rid of either works, having them both doesn't. > More on the various quoting operators below. > > =head2 Non-Interpolating Constructs > > Non-Interpolating constructs are strings in which expressions do not > interpolate or expand. The exception to this rule is that the > backslash character, \, will escape the character that immediately > follows it. I don't think this is right. A single backslash which is not followed by the current quoting delimiter, or the characters q[ or q[[ is not special. It will not escape the following character, it just appears in the string. How about this: Non-Interpolating constructs are strings in which expressions do not interpolate or expand. The exception to this rule is the backslash character C<\>. Most of the time it will just appear in the non-interpolating string as is. However, it also allows you to include the current quoting delimiter or a section which does interpolate in the non-interpolating string. > The base form for a non-interpolating string is the single-quoted > string: 'string'. However, non-interpolating strings can also be > formed with the q[] operator. The q[] operator allows strings to be > made with any non-space, non-letter, non-digit character as the > delimiter instead of '. In addition, if the starting delimiter is a > part of a paired set, such as [, <, or {, then the closing delimiter > may be the matching member of the set. In addition, the reverse holds > true; delimiters which are the tail end of a pair may use the starting > item as the closing delimiter. > > Examples: > > $string = 'string' # $string = 'string' > $string = q|string| # $string = 'string' > $string = q{string} # $string = 'string' > $string = q]string[ # $string = 'string' > > There are a few special cases for delimiters; specifically :, ( and #. >: is not allowed because it might be used by custom-defined quoting > operators to apply a attribute. ( is not allowed because it is used to > pass arguments to attributes. Finally, # is allowed, but there cannot > be a space between the operator and the #. If you're going to change that section above, then you should include something here about escaping the current string delimiter. As mentioned previously, it is possible to include the character you have chosen as the delimiter by preceding it with a C<\>. For instance: 'This string\'s delimiter is \'.' q|This string's delimiter is \|.| Most of the time it's probably better just to use a different delimiter. > A set of braces is a special op that evaluates into the list of words I think it would be better to use the word operator rather than op here, this makes me think <<>> is in the SAS or is a Green Beret or something ;-) > =head2 Interpolating Constructs > > Interpolating constructs are another form of string in which certain > expressions that are embedded into the string are expanded into their > value at runtime. Interpolated strings are formed using the double > quote: "string". In addition, qq[] is a synonym for "", similarly to > q[] being a synonym for ''. The rules for interpolation are as > follows: I think this is backwards qq[] is the general form and "" is the special case synonym. > =item Escaped Characters > # Basically the same as Perl5; also, how are locale semantics handled? > > \t tab > \n newline > \r return > \f form feed > \b backspace We might be losing this one, in favour of \c[^H]. > \a alarm (bell) > \e escape > \0b10 binary char > \o33 octal char > \0o33 octal char > \x33 hex char > \0x1b hex char > \0x[263a] wide form > \c[expr] Named Unicode Character or special notation > > =item Modifiers: C<\Q[]>, C<\L[]>, C<\U[]> > > Modifiers apply a modification to text which they enclose; they can be > embedded within interpolated strings. > > \l Lowercase the following character. > \u Uppercase the following character. > \L[] Lowercase all characters within brackets > \U[] Uppercase all characters within brackets > \Q[] Escape all non-alphanumerics within > brackets (except "}") > > =back > > =head3 Embedding non-interpolated constructs: C<\q[]> > > It is possible to embed a non-interpolated string within an > interpolated string using \q{}. Any characters within the \q{} > construct are treated as if they were in an non-interpolated string. > It is possible to embed a non-interpolated string within a > interpolated string with \q[]. Any characters within a \q[] construct > are treated as if they were in an non-interpolated string. > > Example: > "string \q{$variable}" # $variable will not be interpolated C<\q[]> with c<[]> is the preferred form, you've left some with C<{}>. I think we should use preferred form in the docs. > Examples: > > print << EOF; > The price is $Price. > EOF This is probably a syntax error since << EOF is the start of a qw[] construct. Whether it's a syntax error or lots of warnings about including comments in a qw depends on whether you have >> later in your code. > If you want your here-docs to be indented with the rest of the code, > you'll need to remove leading whitespace from each line manually: > > ($quote = <<'FINIS') =~ s:e/^^\s+//; > The Road goes ever on and on, > down from the door where it began. > FINIS Did Larry change this? the Apocalypse says it's going to do this for you by default. andrew -- Cancer: (June 22 - July 22) Everyone wants the world to love them, but not everyone tries to win the world's affection by baking it an enormous pie.
msg24941/pgp00000.pgp
Description: PGP signature