in reply to return hash table

I'm guessing this is using File::Find, right?. The first problem is you're assigning to %fileInfo the return value of find, not wanted. The second problem, is deep within the guts of File::Find, the return value of wanted is just discarded anyways. This is one of the limited times that you're better off using a global

#!/usr/bin/perl use strict; use warnings; use File::Find; use var qw( $FILEINFO ); find( \&wanted, @directories ); sub wanted { if (!(-d)) { my $fileName = $File::Find::name; $fileName =~ s/\//\\/g; my $fileSize = ( -s $fileName); if (!(exists $FILEINFO{$fileName})){ $FILEINFO{$fileName} = $fileName; print "$FILEINFO{$fileName}\n"; } } }
(I prefer to allcap my globals.)

-derby