Siegfried Heintze wrote:
Consider the following program:

my $me;
$me->{verd_result}->[0][2]=5;
$me->{verd_result}->[0][5]=34;
print "len = ", [EMAIL PROTECTED]>{verd_result}->[0]}};
for (@{$me->{verd_result}->[0]}){
  print "\n v="; print;
}

How is that related to CGI?

It produces this output:

len = 5
 v=
 v=
 v=5
 v=
 v=
 v=34

No, it doesn't. It produces a fatal error.

- Copy and paste code that you post, do not retype it!

- Enable warnings in your program!

How do I modify the program so it only produces this output:

len = 5
 v[2]=5
 v[5]=34

That output wouldn't be correct, since the array contains six elements, not five.


This code:

    my $ref = $me->{verd_result}->[0];
    print "len = " . @$ref, "\n";
    for ( 0 .. $#$ref ) {
        defined $ref->[$_] and print " v[$_]=$ref->[$_]\n";
    }

outputs:
len = 6
 v[2]=5
 v[5]=34

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to