in reply to Can someone Explain 2 lines of code
The first line can be rewritten as:
foreach my $data (@Clec_id) { $count{$data}++; }
Every time the same peice of data appears in the array, that index key is incremented. Thus, if the string 'foo' appears three times in the array, then $count{foo} will be three after the loop runs.
The second line is simply dumping the contents of the hash to STDOUT using a similar construct to the line above it.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
:(){ :|:&};:
Note: All code is untested, unless otherwise stated
|
|---|