I have a cgi name and address application which is mainly working. I am however having trouble retrieving an array of objects.

---abstracted from first screen (working)

my @phn = Phones->load($pcode); Phones->show_all; print $q->hidden("hide_phone", @phn);
--second screen retreives data
Phones->get_param;
included are the returns from the warn on line 934 936, the first time line 937 is commented.
NA.cgi: Phones=HASH(0x84f7f90) at /usr/local/cgi-bin/NA.cgi line 934.
NA.cgi: Phones=HASH(0x84f7f90) at /usr/local/cgi-bin/NA.cgi line 936.
Phones=HASH(0x84f8020) at /usr/local/cgi-bin/NA.cgi line 934.
NA.cgi: Phones=HASH(0x84f8020) at /usr/local/cgi-bin/NA.cgi line 936.
NA.cgi: Phones=HASH(0x84f8a5c) at /usr/local/cgi-bin/NA.cgi line 934.
NA.cgi: Phones=HASH(0x84f8a5c) at /usr/local/cgi-bin/NA.cgi line 936.
when uncommented 937 however fails trying to access the Phones objects, how do get acces to my data?
Can't use string ("Phones=HASH(0x84f7f90)") as a HASH ref while
     "strict refs" in use at /usr/local/cgi-bin/NA.cgi line 937.
package Phones; my @phones; sub load {i -- Loads phone types and phone numbers for one individual +from DB my ($o,$pcode) = @_; my $sel = "select pcode, typephone, phonenumber from phones where +pcode = $pcode"; my $ph = main::do_sql ($sel); my @phone; while (my @fld = $ph->fetchrow_array( ) ) { $fld[1] = $fld[1] || 'H'; push(@phone, \@fld); } my @dummy = ($pcode,'H',''); push(@phone, \@dummy); foreach(@phone){ $obj = new($_); push (@phones, $obj); $obj->trace; } return @phones; } sub new{ my (@d) = @_; my $Phone ={ "pid" => $d[0][0], "o_typ" => $d[0][1], "o_phn" => $d[0][2], "n_typ" => $d[0][1], "n_phn" => $d[0][2], "trc" => 'new', }; bless $Phone, 'Phones'; return $Phone; #return object reference } sub get_param{ my @phn = $q->param("hide_phone"); my $a; foreach $a (@phn){ foreach($a){ foreach $obj ($_){ warn "$obj"; ----------line 934 ------------- foreach ($obj){ warn $_; ----- line 936 warn "$_->{'n_typ'}"; ## $_->trace; } } } } } sub show{ my ($r) = $_[0]; my $phn = $r->{'o_phn'}; my $name = $r->{'o_phn'} || $r->{'pid'}; my $typ = "T$name"; my $def = PhoneTypes->translate($r->{'o_typ'}); my @val = split(':',PhoneTypes->list); $r->{'trc'} = "show->name=$typ"; $r->trace; print $q->popup_menu( -name=>$typ, -values=> \@val, -default=>$def); print $q->textfield( -name=>$name, -default=> $phn); print $q->p; } sub show_all{ foreach(@phones){ $_->show; } }

In reply to CGI hidden retreive array by jw_griffith

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.