diff options
author | lshprung <lshprung@yahoo.com> | 2021-09-12 11:34:50 -0700 |
---|---|---|
committer | lshprung <lshprung@yahoo.com> | 2021-09-12 11:34:50 -0700 |
commit | 7b6dfdf08f6e81bdf0cec9bc4157c12334c64898 (patch) | |
tree | 50a0ccfd1d9941f833af76d41eeb7a244dda1dfa /shared.pl | |
parent | 74ae4b9cf4ae0e56125b0414a62e38ffed8ca19b (diff) |
Fixed issue with db_cmd wrapper and append flag
Diffstat (limited to 'shared.pl')
-rw-r--r-- | shared.pl | 24 |
1 files changed, 24 insertions, 0 deletions
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; |