sub add_record { my ($self, $data) = @_; my @record; for my $key (keys %$data) { my $att_key = $key =~ /[^0-9]/ ? "name" : "fid"; ( my $att_val = lc($key) ) =~ s/[^a-z0-9]/_/g; push @record, { tag => "field", atts => { $att_key => $att_val }, value => $data->{$key}, }; } return post_api("API_AddRecord", \@record); }