open(FILE, "> VIDEO.AVI") or die; binmode(FILE); my $hexcode = "52 49 46 46 f8 e9 08 00 41 ... "; $hexcode =~ s/ //g; for(my $i = 0; $i < length($hexcode); $i += 2) { print FILE chr(hex(substr($hexcode, $i, 2))); } close(FILE); open(IN, "< TTVIDEO.AVI") or die "can't open $oldfile: $!"; open(OUT, ">> VIDEO.AVI") or die "can't open $newfile: $!"; binmode(IN); binmode(OUT); $blksize = (stat IN)[11] || 16384; # preferred block size? while ($len = sysread IN, $buf, $blksize) { if (!defined $len) { next if $! =~ /^Interrupted/; # ^Z and fg die "System read error: $!\n"; } $offset = 0; while ($len) { # Handle partial writes. defined($written = syswrite OUT, $buf, $len, $offset) or die "System write error: $!\n"; $len -= $written; $offset += $written; }; } close(IN); close(OUT);