Well, I asked for a style/effiency breakdown on a stupidly simple little piece of something: A sub for calculating standard deviation.
Time to go check monks to see if it bore any fruit.
Also, during scifi's showing of _The Fifth Element_ (a movie I like quite a bit...it lost a little bit of the charm the second time around, with certain effects not quite being so stunning...but still, neat little movie) I got a few things figured out.
I wrote a test to see if a certain behavior was valid; I know (from, I believe, the Camel) that if you take a hash in array form, it just unwinds the values in pairs.
But if you assigned an array to a hash, would it automatically group as you went? "Key, value, key, value..."?
It's no surprise to anybody reading this that it does; but it was a pleasant one to me. It means the idea I have of filling this hash up is going to be very, very easy.
Anyway, gotta check monks, then I'll code this thing up. Finally. Feels like I've been avoiding work. :\ I have coffee and time; no excuses now.
Tomorrow I will have excuses; I have to get ready for school, which starts Monday! (Assuming, of course, that I'm still eligible for being a student...I really hope I am, now. I'm looking forward to classes.)
Quick Addendum: There are excellent responses, further heightening my guilt about not contributing very much to the Monastery. Regardless, I just learned some new tricks, and I learned them in a way that'll help me apply them.
Hash pair assignments (as in declarations) are lists, plainly and simply. The fat comma operator is just a comma with an extra bit of syntactic sugar. You could as easily say:
my %hash = ('one', 1, 'two', 2);or
my %hash = split(/=|;/, 'one=1;two=2');Anything that creates a list will be interpreted as pairs, in "hash" context. The sooner you start thinking of lists, the sooner you'll unlock the mysteries of map and grep and slices.
Re:The Dirty Little Secret of Hashes and Lists
chaoticset on 2002-01-13T07:21:50
Nothing dirty about it;) I realize I've read that several times over now, and it's just starting to sink in. I'm kind of a slow learner. I try to make up for it by being tenacious.