use strict; use warnings; use Cwd; use JSON; my %hash; my $currDir = Cwd::cwd(); push @{ $hash{$currDir} }, { name => $_, size => ( stat($_) )[7] } for <*>; my $j = encode_json \%hash; print $j;