sub conf2hash { my %argv = @_; =pod usage: conf2hash( file=>'path/2/file', hashref=> \%yourhash, splitchar=>'=', commentchar=> '#'); if splitchar is null, default is = sign if commentchar is null, default is # mark # one key val pair per line # returns 0 on errors =cut defined $argv{splitchar} or $argv{splitchar}='='; defined $argv{hashref} or return 0; defined $argv{commentchar} or $argv{commentchar}='#'; defined $argv{file} or return 0; open (IN, "< $argv{file}") or die($!); while () { if ( $_=~m/^$argv{commentchar}|^\s+$/ ) { next;} $_=~s/\s//g; my @a = split(/$argv{splitchar}/,$_); ${$argv{hashref}}{$a[0]}=$a[1]; } close IN; return 1; } #### THIS=that name=joe height=heyman #this is a comment age=14 #### my @a = split(/$argv{splitchar}/,$_); #and then, place it into the hash.... ${$argv{hashref}}{$a[0]}=$a[1]; #### split(/$argv{splitchar}/,$_); ${$argv{hashref}}{$_[0]}=$_[1]; # is that ok ?? # and what about some thing like.. # (and I DONT KNOW the syntax, that's why im here!!) ( ${$argv{hashref}}{$_} = $_ )= split(/$argv{splitchar}/,$_); #is that totally making it up ?