open my $fh, "<", $file or die $!; while (<$fh>){ my ($key,$val) = split /\t/; substr($bin,$key*4,4,pack("N",$val)); }