in reply to Class::DBI insert error

In scalar context, search() returns an iterator. You can't use that as a record value.

Either do:

# Note the braces to force list context on the left hand side my ($roleid) = autocd::roles->search(rolename => $rolename);

or

my $role_iter = autocd::roles->search(rolename => $rolename); if (!$role_iter->count || !$username){ return ""; } my $roleid = $role_iter->first;

I'd go for the first option.