[Newb] Mangling parameters, avoiding recursions?

[email protected] ("Ekki Plicht (DF4OR)")
Newsgroups perl.moose
Message-ID <CAMmwEgNYgwuBtn67c9LDHqoM7KWSYSKrrfYa3ZqYOkFzY-usSw@mail.gmail.com>
Hi.
New to Moose, my first larger project with it.

My object receives data from an external website, and that data needs
to be cleaned and sanitized a lot. Not wanting to create exotic custom
types for each data item, I tried to use 'around" method modifiers to
mangle the data.

Example:
around 'kdnr' => sub {
    my ($org, $self, $value) = @_;
    return $self->kdnr unless $value;

$debugcount++;
warn "in around kdnr $debugcount\n";

    $value = '' unless ($value =~ m/\d{5}/);
    return $self->kdnr($value);
};

This item must be 5 digits, or not present at all, but our customers
manage to enter all kinds of creative stuff here. Checking on the
website is no option, so I want to do it here.

When reading the data set the debugcounter skyrockets within seconds,
a little bit later I get a "Deep recursion" error and much later the
process is killed.

I am aware that 'around' methods probably aren't the best place to
sanitize data, but how else? Custom types? I have seen a Module
MooseX::Mangle, but I am not sure if this does help me with that
recursion thing.

Ideas, hints? Fundamental misunderstanding on my side when using Moose?

TIA,
Ekki
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.