diff options
author | lshprung <lshprung@yahoo.com> | 2021-09-13 16:28:16 -0700 |
---|---|---|
committer | lshprung <lshprung@yahoo.com> | 2021-09-13 16:28:16 -0700 |
commit | d654b5c03c576bf8962960df9febf3ad37e29ea2 (patch) | |
tree | 05725f26906ff0f2b2d6b703ee280ce38e593ac1 /shared.pl | |
parent | 232a02548e314b8cb69d31fd98fe2395ca5520cb (diff) |
Altered behavior of db_cmd and array_handler
Diffstat (limited to 'shared.pl')
-rw-r--r-- | shared.pl | 25 |
1 files changed, 23 insertions, 2 deletions
@@ -1,4 +1,25 @@ -# File to hold shared variables and subroutines +# File to hold shared subroutines + + +# Handle digging into non-scalar tags and other deep arrays +# @_[0] -> array tag/deep array +sub array_handler { + my @output; + + for my $i (@_){ + # If another array, recursively handle + if (ref($i) eq 'ARRAY'){ + push(@output, array_handler(@$i)); + } + + # If scalar, append to output normally + elsif (!ref($i)){ + push(@output, "$i"); + } + } + + return @output; +} # Wrapper to handle sqlite commands, return an array of returned lines from sqlite output @@ -18,7 +39,7 @@ sub db_cmd { } # Build output array - return($sth->fetchrow_array); + return($sth->fetchall_arrayref); } 1; |