http://www.perlmonks.org?node_id=829716

Kirche has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to count number of files for each extension in a folder:
opendir H, './'; $ext{$1} += (m/([^.]+)$/) for grep { -f } readdir H; closedir H; print "$_ - $ext{$_}\n" for keys %ext;
I'm getting following error: Use of uninitialized value in hash element at line 4. But if i replace += with = it shows no error. What i'm doing wrong?