#!/usr/bin/perl use strict; use warnings; use Digest::MD5 qw(md5_hex); my @content; { open my $fh, '<', 'null_byte.txt' or die $!; local $/ = "\0"; while ( my $entry = <$fh> ) { push @content, $entry, md5_hex( $entry ); } close $fh; } open my $fh, '>', 'null_byte_new.txt' or die $!; print $fh join "\0", @content; close $fh;