\Q und \E quoten?? Wo ist die PerlDoc dazu??
Aqua
- perl
Hallo!
Bin gerade über folgende Zeile Perl-Code gestoltpert:
if (grep(/^\Q$foo\E$/, @array))
\Q und \E sollen angeblich alles was kein Buchstabe/Zahl ist quoten.
Also einen \ davor machen.
wenn also $foo z.B. *-. enthalten würde,
würde es gequotet werden mit \ davor also.
Zitat aus der PERLDOC QUOTEMETA:
This is the internal function implementing the \Q escape in double-quoted strings.
Eine Erklaerung zu \E habe ich aber noch nirgens gefunden
Wo gibt es eine offizielle Seite (Perldoc oder so)
wo genau beschrieben wird warum in dem source den ich pastete
\Q und \E gemacht wird.
Danke!
Aqua
Hallo Aqua,
[...]
perldoc perlre:
[...]
\E end case modification (think vi)
\Q quote (disable) pattern metacharacters till \E
[...]
You cannot include a literal "$" or "@" within a "\Q" sequence. An
unescaped "$" or "@" interpolates the corresponding variable, while
escaping will cause the literal string "$" to be matched. You'll need
to write something like "m/\Quser\E@\Qhost/".
[...]
Gruesse,
CK