#!/usr/bin/perl use strict; use warnings; my $cmd = 'ls -l [0-9]*.pl'; my %fileinfo; open my $capt, "$cmd |" or die "Couldn't run shell/'$cmd': $!"; while (<$capt>) { my ($mode, $links, $owner, $group, $size, $date, $time, $fname) = split; my ($type, $perm) = unpack "aa*", $mode; $fileinfo{$fname} = { SIZE => $size, DATE => "$date $time", OWNER => $owner, PERM => $perm, } if $type eq '-'; } use Data::Dumper; $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; print Dumper \%fileinfo; __END__ $VAR1 = { ... '828461.pl' => { 'DATE' => '2010-03-13 21:20', 'OWNER' => 'almut', 'PERM' => 'rwxr--r--', 'SIZE' => '502' }, '828472.pl' => { 'DATE' => '2010-03-13 20:31', 'OWNER' => 'almut', 'PERM' => 'rwxr--r--', 'SIZE' => '83' }, '828529.pl' => { 'DATE' => '2010-03-14 12:52', 'OWNER' => 'almut', 'PERM' => 'rwxr--r--', 'SIZE' => '807' } }; #### #!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); # for date formatting my %fileinfo; for my $fname (glob "[0-9]*.pl") { my ($mode, $uid, $size, $mtime) = (stat $fname)[2,4,7,9]; $fileinfo{$fname} = { SIZE => $size, DATE => strftime("%Y-%m-%d %H:%M", localtime($mtime)), OWNER => scalar getpwuid($uid), PERM => sprintf("%o", $mode & 07777), } if -f _; } # ...dump %fileinfo