Jim Gibson <jimsgib...@gmail.com> writes: [...] thanks for the tips on timing
> The general advice is not to worry about execution time until it becomes an > issue. In other words, just get your program to do what you want it to do, > then try to speed it up only if it is taking too long. That sound sensible. [...] >>> . . . . . . $data{ $_ }{ $r2 }. >> >> I guess I should have asked why is it incrementing that data and why >> is $r2 in squiggly brackets? > > The braces ({}) mean that %data is a "hash-of-hashes", i.e., the values of > the elements of %data are references to hashes. Needless to say, I'm a bit confused here.... googling on `hash of hashes' has plenty of hits, but looking through a few, so far has only helped confuse me. One at: http://htmlfixit.com/cgi-tutes/\ tutorial_Perl_Primer_014_Advanced_data_constructs_A_hash_of_hashes.php Looks like it might be helpful. I can see that $data{ $_ } is the value side of a hash pair in the hash named %data, but still not understanding what `{ $r2 }' is. Seems like if you revealed the values in those variables it would look like: ./some/dir/filename{ filename } { ./dir2_passed_in_from_cmdline }++; ./some/dir/filename => filename Here, I'm still lost. other than that (./some/dir/filename indexed by $r2 is the name of a top level filename) directory passed from the cmdline. I'm still lost about the right side. Doesn't it usually mean, when you see something between {} that you are executing something?.. but $r2 is a directory name, not sure how you execute that. So assuming I'm way off base there. I must be coming over like a total dope... but this is very confusing to me. > The '++' is counting the number of times that the primary key $_ and > secondary key $r2 occur when that line is executed. Your program may be > interested in the actual number, or it may just be interested that the key > combination appeared at all (you didn't include enough context to tell.) So far, I just wanted to see the matches on STDOUT. But yes, I will need to handle the hits.. I'll need to match them up with there counterpart in the other toplevel directory... probably by looking at the sizes. Like if one value of hash1 matched 4 values of hash2... I'll want to look at the sizes of the associated keys. One from hash1 and the 4 from hash2, possibly even a diff of the files before finally deciding what to do next with them. I'm thinking I'll do that in a dispatch table..... of some kind. But so far, I just want to understand how to see the matches, that is, print them. And of course the overriding purpose is to learn how to manipulate hashes in ways that will help me in other projects later on. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/