Hey Monks, I am rather new to Perl and I cannot quite get my head around why this code doesn't work:
my %p = ( outputdir => undef, rptfmt => 'html', rptname => undef, rptfile => '', title => undef, headers => [], data => [], stdout => 0, ); .... cut ..... my $rpt = Report->new($p{title}, $p{headers}, $p{data});
Module
sub new { my ($class,$title,$head,$data,$info) = @_; my $self = {}; bless ($self, ref ($class) || $class); $title ||= ""; $head = [] if !$head || ref $head ne 'ARRAY'; $data = [] if !$data || ref $data ne "ARRAY"; #$rows = $#{@$data} if $data || ref $data eq "ARRAY" || ref $$data +[0] ne "ARRAY"; my ($cols,$rows,@justify) = ($#{@$head},$#{@$data});
The module fails on the last line shown. The error is: Can't use string ("9") as an ARRAY ref while "strict refs" in use at .//Report.pm line 72. I am following an example I was given so it must be outside the module that is wrong.. Any ideas?

In reply to Cannot find error : Can't use string ("9") as an ARRAY ref while "strict refs" ... by smoky

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.