in reply to Perl 5.6.1 Regular Expression problems (UTF8 ?)

It is a quirk of Perl's error reporting that an error inside an if block may give the number of the line on which the if block starts, rather than the line within the if block where the error actually occured. Thus, you may have to look within the if block that starts on line 30 for the source of the error.

Looking at tachyon's post, I see that this if statement is followed by a call to quotemeta. I expect that's what is causing the problem; quotemeta() backslashes everything except word characters, so it might use a function called IsWord to figure out if a certain UTF8 character should be backslashes or not.

Unfortunately, I don't know why the IsWord function has not been loaded. You may want to produce a small test case and submit a bug report using the perlbug utility that comes with Perl.

  • Comment on Re: Perl 5.6.1 Regular Expression problems (UTF8 ?)

Replies are listed 'Best First'.
Re: Re: Perl 5.6.1 Regular Expression problems (UTF8 ?)
by Pitr (Novice) on Jul 06, 2001 at 17:34 UTC
    Thanks for the feedback so far. I tried to simulate the problem with the following piece of code:

    #!/usr/bin/perl -w print "Content-Type: text/html\n\n"; my $value = "ciaoslave"; my $allowed = '[\w\d\s\-]{1,15}'; my $escape = "yes"; if($value =~ /^$allowed$/){ print (($escape eq "no") ? $value : quotemeta($value)); }else{ print "Fail!"; } print "\n";

    When I call this script through a webbrowser it works.. and does not give the error that occurred earlier.

    Perhaps the XML::Simple module effects the behaviour in some way ?

    Thanks again,
    - Pitr
Re: Perl 5.6.1 Regular Expression problems (UTF8 ?)
by Pitr (Novice) on Jul 10, 2001 at 18:37 UTC
    Replacing '\w' by 'a-zA-Z' seems to do it - One step closer to the solution :)
    Pitr
      perl -wle 'BEGIN { $SIG{__DIE__} = sub { print "Catched SIGDIE: @_";ex +it(-1) }} use utf8; /^\w$/;'

      Results in:
      Catched SIGDIE: Can't locate object method "IsWord" via package "main" + (perhaps you forgot to load "main"?) at /usr/local/lib/perl5/5.6.1/u +tf8_heavy.pl line 30.

      This code illustrates the problem: the eval() done by utf8_heavy.pl fails and calls the die-handler which is set within the BEGIN block. I think this should not happen, because the 'die' within eval() is in a different scope than the position where the Die-handler is set.
        Actually, according to the documentation, this is correct behavior. Die handlers carry over into evals.