I'm having trouble returning data from a module I'm building.

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.