#!/usr/bin/perl use strict; use warnings; use feature qw/say/; use DBD::SQLite; use Data::Dumper; our $dbfile = "test.db"; my $dbh = DBI->connect("dbi:SQLite:$dbfile", undef, undef, { AutoCommit => 1, RaiseError => 1 }); # create table, if necessary $dbh->do("CREATE TABLE IF NOT EXISTS data (skey TEXT PRIMARY KEY, svalue TEXT);"); # insert data $dbh->do("INSERT OR REPLACE INTO data (skey, svalue) VALUES ('Stuff', 'Ge 1:1-more \&stuff\& here ');"); # fetch data my $sth = $dbh->prepare("SELECT skey, svalue FROM data WHERE skey = 'Stuff';"); $sth->execute(); my $results = $sth->fetchall_hashref("skey"); say Dumper $results; #### $VAR1 = { 'Stuff' => { 'svalue' => 'Ge 1:1-more &stuff& here ', 'skey' => 'Stuff' } };