conan156 has asked for the wisdom of the Perl Monks concerning the following question:

The perl version is v5.6.0 for hpux when I search using =~ any string that contains \P such as \\Printer1\P1275 I run into this error Can't find unicode character property definition via main->5 or 5.pl at unicode0 How can I disable perl from thinking \P is a unicode character? Thank You

Replies are listed 'Best First'.
Re: Unicode error (\Q)
by tye (Sage) on Oct 31, 2003 at 19:09 UTC

    Because

    /$regex/
    interprets the contents of $regex as a regular expression. What you want is:
    /\Q$string\E/
    which interprets the variable contents as a string (by backslashing any non-"word" characters the same as quotemeta does).

                    - tye
Re: Unicode error
by Thelonius (Priest) on Oct 31, 2003 at 18:01 UTC
    Any literal backslashes in regular expressions need to be escaped: \\\\Printer1\\P1275