Calls the module:
my (@cols, @hw) = new Itiv::Hw->all_hw($dbh, $filter);
The module:
package Itiv::Hw; use Exporter; use lib "/var/www/itiv/modules"; use DBI; use MHQ::DBI qw(:all); use warnings; use strict; use vars qw($VERSION @ISA @EXPORT); our $VERSION = 1.00; our @ISA = qw(Exporter); our @EXPORT = qw(&new &all_hw); sub new { my $class = shift; my $self = {}; return bless $self, $class; } sub all_hw { my ($self, $dbh, $filter) = @_; my $statement = 'SELECT hardware.hid as Hardware, description as Description, DATE_FORMAT(created, \'%Y-%m-%d\') as Created, received as Received, hw_type.type as Type, model_number as Model, manu_serial as Serial, poid as PO, hardware.hid as HID, users.uname as User FROM hardware, users, hw_type WHERE hardware.uid = users.uid AND hardware.hwtid = hw_type.hw +tid'; if ($filter ne 'none'){ $statement .= " AND hardware.hwtid='$filter'"; } $statement .= " ORDER BY description;"; my @cols = qw/ Description Type Created Received Model Serial PO HID User/; # gets list of hashed structure my @hw = dbi_exec_for_loh($dbh, $statement); return (\@cols, \@hw); } 1;
Cols ends up having 2 or 3 entries, instead of 10. Hw is empty.
Neil Watson
watson-wilson.ca
In reply to The correct way to return arrays from a module by neilwatson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |