An internet search didn't show up an example of inserting data into a PostgreSQL array (quite a few for retrieving data, though), so I thought I'd post this here.
Given a table:
create table my_table(
id serial,
description varchar(255),
associated_str_data varchar(255)[],
associated_int_data integer[]);
just using arrayrefs for data supplied to the placeholders does the job:
my $desc = "A description";
my @assoc_str_data = ("string 1", "string 2");
my @assoc_int_data = (1,2,3);
$dbh->do("insert into my_table(description, associated_str_data, assoc
+iated_int_data) values (?,?,?)",
undef, $desc, \@assoc_str_data, \@assoc_int_data);
Checking the result in psql shows the data inserted OK:
# select * from my_table;
id | description | associated_str_data | associated_int_data
----+---------------+-------------------------+---------------------
2 | A description | {"string 1","string 2"} | {1,2,3}
(1 row)