in reply to Re: Strange regexp problem
in thread Strange regexp problem

I need the eval because I have to avoid breaking UTF-8 strings.

Replies are listed 'Best First'.
Re^3: Strange regexp problem
by moritz (Cardinal) on Aug 28, 2007 at 10:44 UTC
    Uhm, really?

    If you encode UTF-8 strings into perl's internal format, you don't need that kind of hack:

    use Encode qw(encode decode); my $str = # some input method here; $str = encode("utf8", $str); # do your pattern matching here print decode("utf8", $str);

    Or look

    If you have non-ascii characters in the source of your script, use utf8;. And take a look at perluniintro and perlunicode.

    Or in what way do utf-8 strings "break" without the string eval?

Re^3: Strange regexp problem
by akho (Hermit) on Aug 28, 2007 at 11:52 UTC
    As moritz explains above, you don't.

    And we may give you a much better answer if you told us what you're trying to achieve with that regexp — few here understand what \x(w{2}) is supposed to mean or why that w had to be escaped inside the eval.

    Avoid the XY problem.