open( $l, "; close( $l ); my @keys = split( /\s+/, $lines[0] ); shift( @keys ); # to remove the # as the first field foreach my $line ( @lines ) { # Skipping if the line is empty or a comment next if ( $line =~ /^\s*$/ ); next if ( $line =~ /^\s*#/ ); my %hash; @hash{ @keys } = split( /\s+/, $line ); # then do whatever you have to }