First of all, the construct foreach(qw(name to file action virus)) { $gCurRec->{$_}=''; } can be expressed very succinctly using so called hash slices, i.e. my @columns = qw(name to file action virus); @{ $gCurRec }{ @columns } = ('') x @columns; #### $gCurRec = { map { ( $_ => "" ) } qw{ from to file action virus } };