I'am using AUTOLOAD in some kind of Object-Relation Mapping class. My application just freeze when working with utf8 data. With non-utf8 everything is OK.
Base class:
package XNObject; use strict; sub new { my $class = shift; my %fields = ( _modified => 0, _actual => 0, _f => {}, # "real" object fields ); my $self = { %fields, }; bless $self, $class; } our $AUTOLOAD; sub AUTOLOAD { my $self = shift; my $value = shift; my $type = ref($self) or croak "No class for AUTOLOAD"; my $name = $AUTOLOAD; $name =~ s/.*://; if(defined($value)){ return $self->{_f}->{$name} = $value; }else{ return $self->{_f}->{$name}; } } # other stuff skipped 1;
Derived class:
package ForumMessage; use strict; use base qw(XNObject); sub new { my $class = shift; my $self = $class->SUPER::new(@_); my %fields = ( _type => 'forum_message', ); @{$self}{keys %fields} = values %fields; bless $self, $class; } #other stuff skipped 1;
Using in app:
use strict; use ForumMessage; my $msg = ForumMessage->new; my $body = "This is a test"; # utf8 string here $msg->body($body); # strange pause with utf8 string print $msg->body; # works fine with any data #$msg->user_id($user_id); #$msg->_store;

Works fine. Only while $body is non-UTF-8 string.

In other case $msg->body($body) produces strange pause (15-60 secs) with 100% CPU load.

Any ideas?

$ perl -v This is perl, v5.8.9 built for i386-freebsd-64int

In reply to Strange AUTOLOAD's bevavior with utf8 data by ascray

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.