Re: Quotes for value of <skip:> directive.

[email protected] (Damian Conway)
Newsgroups perl.recdescent
Message-ID <[email protected]>
Carl asks:
 
   > This script works great. However, if I change the value of the skip
   > directive so that it uses double quotes instead of single quotes:
   > 
   > <skip: "\.*">
   > 
   > the grammar fails to parse the input. However, if I put square
   > brackets around the escaped dot:
   > 
   > <skip: "[\.]*">
   > 
   > the grammar starts working again:
   > 
   > How does this work this way?

This small test program may help you figure out what's going wrong:

	print "\.*", "\n";
	print '\.*', "\n";

Backslash works differently inside single and double quotes.
Try:

      <skip: "\\.*">

The reason the third variant:

      <skip: "[\.]*">

works is because it becomes the pattern:

	/[.]/

which is a literal dot.

Damian
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.