# array mapping PPN to hash of info key => value
# element keys:
# LPN => logical page number stored at this block
# XPPN => array of unknown numbers found with this block
my @PPN = ();
####
# array mapping LPN to array of PPNs that store copies
# each element is an array of PPNs
my @LPN = ();
####
use constant NAND_PAGE_SIZE => 16384; # or whatever...
{
open IMAGE, '<', $image_file_name or die "$image_file_name: $!";
local $/ = \NAND_PAGE_SIZE;
while () {
my $ppn = (tell IMAGE) / NAND_PAGE_SIZE;
my $lpn = get_LPN($_);
$PPN[$ppn] = { LPN => $lpn, XPPN => [ get_XPPNs($_) ] };
push @{$LPN[$lpn]}, $ppn;
}
close IMAGE;
}