G
Guy
I bought the 3 books: Learning Perl, Intermediate Perl, Mastering Perl, and
what I've read is great. But the only info I've found so far on \Q \E is on
page 24 of Learning Perl which says "Quote non-word characters by adding a
backslash until \E." Does this mean metacharacters?
And I read on http://www.informit.com/articles/article.aspx?p=24468
that the full list of metacharacters is \, |, ^, $, *, +, ?, ., (, ), [, {
So I wrote the following lines to see the results, but I don't seem to grasp
what is happening and what makes \Q \E useful. You may want to ignore the
<BR> as in my case I am printing to HTML.
my $str1 = "\a|a^a$a*a+a?a.a(a)a[a{a";
my $str2 = "\Q\a|a^a$a*a+a?a.a(a)a[a{a\E";
my $str3 = "\\Q\a|a^a$a*a+a?a.a(a)a[a{a\\E";
print "</CENTER>";
print '\a|a^a$a*a+a?a.a(a)a[a{a<BR>'; # the original string
print "$str1 <BR>";
print "$str2 <BR>";
print "$str3 <BR>";
This is the results.
\a|a^a$a*a+a?a.a(a)a[a{a
|a^a*a+a?a.a(a)a[a{a
\\|a\^a\*a\+a\?a\.a\(a\)a\[a\{a
\Q|a^a*a+a?a.a(a)a[a{a\E
Can someone show me a useful example of \Q \E ? All info is appreciated.
Guy D
what I've read is great. But the only info I've found so far on \Q \E is on
page 24 of Learning Perl which says "Quote non-word characters by adding a
backslash until \E." Does this mean metacharacters?
And I read on http://www.informit.com/articles/article.aspx?p=24468
that the full list of metacharacters is \, |, ^, $, *, +, ?, ., (, ), [, {
So I wrote the following lines to see the results, but I don't seem to grasp
what is happening and what makes \Q \E useful. You may want to ignore the
<BR> as in my case I am printing to HTML.
my $str1 = "\a|a^a$a*a+a?a.a(a)a[a{a";
my $str2 = "\Q\a|a^a$a*a+a?a.a(a)a[a{a\E";
my $str3 = "\\Q\a|a^a$a*a+a?a.a(a)a[a{a\\E";
print "</CENTER>";
print '\a|a^a$a*a+a?a.a(a)a[a{a<BR>'; # the original string
print "$str1 <BR>";
print "$str2 <BR>";
print "$str3 <BR>";
This is the results.
\a|a^a$a*a+a?a.a(a)a[a{a
|a^a*a+a?a.a(a)a[a{a
\\|a\^a\*a\+a\?a\.a\(a\)a\[a\{a
\Q|a^a*a+a?a.a(a)a[a{a\E
Can someone show me a useful example of \Q \E ? All info is appreciated.
Guy D