prom / hex-merge

#!/usr/bin/perl
# Merge a low and high roms into a single image file
use warnings;
use strict;

my $f1 = shift;
my $f2 = shift;

undef $/;
open BIN1, "<$f1" or die;
my $bin1 = <BIN1>;
open BIN2, "<$f2" or die;
my $bin2 = <BIN2>;

my @b1 = split //, $bin1;
my @b2 = split //, $bin2;

my $b1_len = length $bin1;
my $b2_len = length $bin2;
die "File lengths $b1_len != $b2_len\n"
	unless $b1_len == $b2_len;

for my $i (0..$b1_len-1)
{
	print $b2[$i], $b1[$i];
}

__END__
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.