From 7b6dfdf08f6e81bdf0cec9bc4157c12334c64898 Mon Sep 17 00:00:00 2001 From: lshprung Date: Sun, 12 Sep 2021 11:34:50 -0700 Subject: Fixed issue with db_cmd wrapper and append flag --- shared.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 shared.pl (limited to 'shared.pl') diff --git a/shared.pl b/shared.pl new file mode 100644 index 0000000..ea2fdfd --- /dev/null +++ b/shared.pl @@ -0,0 +1,24 @@ +# File to hold shared variables and subroutines + + +# Wrapper to handle sqlite commands, return an array of returned lines from sqlite output +# @_[0] -> database handle +# @_[1] -> command/statement +# @_[2] (optional) -> output statement +sub db_cmd { + my $sth = $_[0]->prepare($_[1]); + + if ($sth->execute < 0){ + die $DBI::errstr; + } + + # DEBUG + if (!$options{quiet} and defined $_[2]){ + print "$_[2]\n"; + } + + # Build output array + return($sth->fetchrow_array); +} + +1; -- cgit