|go ahead... be a heretic|
What way to weigh an AoA?by SamCG (Hermit)
|on May 17, 2006 at 00:17 UTC||Need Help??|
SamCG has asked for the wisdom of the Perl Monks concerning the following question:
If it please the monks, I'll start with an explanation. Actually, this node was going to have quite different questions, but writing this node helped me sort some of them out.
I set up a sqlite database, with a users table:
I did a sql query in a module I wrote:
I have no problem passing in the database handle reference, and the $users reference comes back fine. But then I have to iterate through it. It took me a while to figure out how to do this, eventually using Data::Dumper to figure out what my data structure actually looked like -- an array of arrays.
I figured out how to iterate through this with print "$user->[$_]->, $user->[$_]->\n" for 0..5; However, I'd like to just use the last subscript of the array (a la something like $$#user). However, 0..$$#user seems to go far higher than I'm expecting. It gives me all the users, and then a couple of hundred commas (note the comma in the print statement, above). Actually, when I print $$#user alone, it gives me 3460. I'm a bit surprised it doesn't either 1) just give me all the values and stop, or 2) go on forever. I'd guess it's give me some type of exponential set. How do I get it to give me what I want (7, in this case with 8 users)?
I don't think I would have figured it out from this, as it pretty much tells me what I'd already determined.
s''limp';@p=split '!','n!h!p!';s,m,s,;$s=y;$c=slice @p1;so brutally;d;$n=reverse;$c=$s**$#p;print(''.$c^chop($n))while($c/=$#p)>=1;