jw_griffith has asked for the wisdom of the Perl Monks concerning the following question:
---abstracted from first screen (working)
--second screen retreives datamy @phn = Phones->load($pcode); Phones->show_all; print $q->hidden("hide_phone", @phn);
included are the returns from the warn on line 934 936, the first time line 937 is commented.Phones->get_param;
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; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: CGI hidden retreive array
by jeffa (Bishop) on Jun 10, 2003 at 14:46 UTC | |
|
Re: CGI hidden retreive array
by benn (Vicar) on Jun 10, 2003 at 14:53 UTC | |
|
Re: CGI hidden retreive array
by davorg (Chancellor) on Jun 10, 2003 at 14:55 UTC | |
|
Re: CGI hidden retreive array
by Jenda (Abbot) on Jun 10, 2003 at 15:35 UTC |