That's gives me all the keys (50) and I have only filled in three stories. I would expect to get 30 in that case but something isn't quite right at 'if (defined($r->param...' because both keys and vaules return 50 which is the total number of possible fields and not simply the ones with a values.
sub parse_request { my $r = shift; my @no = (1...10); my @flds = qw/head des spllink storyfrom storylink/; my $l; my %hash; for ($l = 1;$l <=10;++$l) { foreach my $p (@flds) { my $param = "a"."$l"."_"."$p"; if (defined($r->param("$param")) ) { # print STDERR "\$hash{$param} => ".$r->param("$param")."\n"; $hash{$param} = $r->param("$param"); } } } Thanx. Dp. On 8 Apr 2004 at 12:13, James Edward Gray II wrote: > On Apr 8, 2004, at 12:03 PM, Dermot Paikkos wrote: > > > Hi, > > > > I have written something in ModPerl (extremely proud of myself) but > > have hit a snag. The program returns the input from a form. > > Unfortunately I can't post a url to the form. The form has ten > > sections, each section is a story synopsis. Within each story are 5 > > fields. I gather all the form data into a hash but once I have done > > that I don't know how to find out how many stories I have. > > > > I tried $num = %hash and this gave me "38/64" which I can't make > > sense of. $num = values(%hash) gives me the total number of fields > > (50) and @num = values(%hash) seems to pour everything into the > > somewhere in @num but I can't see to untangle it (I can't see > > anything in $num[0]). > > > > Can anyone help?? > > Sure: > > my $count = keys %hash; > > James > > ~~ Dermot Paikkos * [EMAIL PROTECTED] Network Administrator @ Science Photo Library Phone: 0207 432 1100 * Fax: 0207 286 8668 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>