Q:\>perl -w tmp.pl Global symbol "%myHash" requires explicit package name at tmp.pl line 4. Global symbol "$myHash" requires explicit package name at tmp.pl line 17. Global symbol "%myHash" requires explicit package name at tmp.pl line 22. Execution of tmp.pl aborted due to compilation errors. Q:\>type tmp.pl #!/usr/bin/perl use warnings; use strict; %myHash=(); sub populateHash { my $MY_FILE="file.properties"; open my $PFILE, '<', $MY_FILE or die "Cannot open '$MY_FILE' $!"; LINE: while (<$PFILE>) { # now read the line and remove all white spaces, tab and new line chars or any t railing spaces $_ =~ s/\s+$//; next LINE if (/^\s*#/); # ignore commented lines next LINE if (/^$/); # ignore null lines my $n=substr($_,0,index($_,'=')); my $v=substr($_,index($_,'=')+1); $myHash->{$n}=$v; } close $PFILE; } &populateHash(); while ( my ($key, $value) = each(%myHash) ) { print "From myHash --> $key => $value\n"; }