in reply to scale of large data file and output them in certain format

Perhaps this will help get you started:

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $data1 = 'master.txt'; my $data2 = 'child.txt'; open my $F1, '<', $data1 or die qq["$data1" can\'t be opened: $!]; open my $F2, '<', $data2 or die qq["$data2" can\'t be opened: $!]; my %accounts; while ( <$F1> ) { my ( $number, $name ) = unpack 'A4 A*', $_; $accounts{ $number }{ master } = $name; } while ( <$F2> ) { my ( $number, $child ) = unpack 'A4 A*', $_; $accounts{ $number }{ child } .= "$child\n"; } my $page = 1; for my $key ( sort keys %accounts ) { print ' ' x 20, $accounts{ $key }{ master }, "\n"; print $accounts{ $key }{ child }; print ' ' x 20, "Page ", $page++, "\n\n"; }