Re: Size of a hash

2007-10-19 Thread Gunnar Hjalmarsson
Joseph L. Casale wrote: The first hash has several entities, one of which is 'object'. Inside this hash, I have several other hashes, all of which are actually named '0' and up. I guess I overlooked just iterating through that second hash. I am now stuck in leveraging those hashes as the synt

RE: Size of a hash

2007-10-19 Thread Joseph L. Casale
ED] On Behalf Of Tom Phoenix Sent: October-19-07 3:32 PM To: Joseph L. Casale Cc: beginners@perl.org Subject: Size of a hash On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Is there a way to compute the size of a hash? Yes; use the keys() function in a scalar context to get the

Size of a hash

2007-10-19 Thread Tom Phoenix
On 10/19/07, Joseph L. Casale <[EMAIL PROTECTED]> wrote: > Is there a way to compute the size of a hash? Yes; use the keys() function in a scalar context to get the number of key-value pairs in the hash. my $count = keys %hash; > I have a hash of hashes of hashes etc... and need

Re: How to get the size of a hash?

2004-04-08 Thread Rob Dixon
Dermot Paikkos wrote: > > I have written something in ModPerl (extremely proud of myself) [and stuff] Well done Dermot. Writing functional code and being proud of it is about 88% of the job. Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to get the size of a hash?

2004-04-08 Thread James Edward Gray II
On Apr 8, 2004, at 12:44 PM, Dermot Paikkos wrote: Got it: if ($r->param("$param") ne "" ) { That works. if (length $r->param($param)) { should also work. Note: I don't quote the variable name. It's not needed. I was suggesting just dropping defined(): if ($r->param($param)) { That probab

Re: How to get the size of a hash?

2004-04-08 Thread Dermot Paikkos
Got it: if ($r->param("$param") ne "" ) { $num is now 10 and that right (only 2 stories this time). Thanx v.much for your time. Dp. On 8 Apr 2004 at 12:33, James Edward Gray II wrote: > On Apr 8, 2004, at 12:23 PM, Dermot Paikkos wrote: > > > That's gives me all the keys (50) and I have

Re: How to get the size of a hash?

2004-04-08 Thread Dermot Paikkos
You are right on the money. I am getting empty strings: $hash{a1_head} => This is my first headline $hash{a1_des} => This is my first description $hash{a1_spllink} => This is my first SPL link $hash{a1_storyfrom} => The New Scientist $hash{a1_storylink} => http://www.newsciencetist.com $hash{a2_he

Re: How to get the size of a hash?

2004-04-08 Thread James Edward Gray II
On Apr 8, 2004, at 12:23 PM, Dermot Paikkos wrote: 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 poss

Re: How to get the size of a hash?

2004-04-08 Thread Dermot Paikkos
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 value

Re: How to get the size of a hash?

2004-04-08 Thread James Edward Gray II
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

How to get the size of a hash?

2004-04-08 Thread Dermot Paikkos
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 d