#!/usr/bin/perl use strict; use warnings; while (defined (my $x= )) { process_record ($x) if ($x =~ /^JOB::/) } sub process_record { my $job = shift; chomp $job; print "$job\n"; process_sub_record(); process_sub_record(); } sub process_sub_record { my $sub_record = ; chomp $sub_record; for (1..4) { my $nextLine = ; chomp $nextLine; print "~~$sub_record~~ ", "$nextLine\n"; } } =PRINTS: JOB::HEREISASTRING ~~Something~~ StringA ~~Something~~ StringB ~~Something~~ StringC ~~Something~~ StringD ~~Something Else~~ StringE ~~Something Else~~ StringF ~~Something Else~~ StringG ~~Something Else~~ StringH JOB::HEREISANOTHERSTRING ~~Something~~ StringI ~~Something~~ StringJ ~~Something~~ StringK ~~Something~~ StringL ~~Something Else~~ StringM ~~Something Else~~ StringN ~~Something Else~~ StringO ~~Something Else~~ StringP =cut __DATA__ JOB::HEREISASTRING Something StringA StringB StringC StringD Something Else StringE StringF StringG StringH JOB::HEREISANOTHERSTRING Something StringI StringJ StringK StringL Something Else StringM StringN StringO StringP #### #!/usr/bin/perl use strict; use warnings; while (defined (my $x= )) { process_record ($x) if ($x =~ /^JOB::/) } sub process_record { my $job = shift; chomp $job; print "$job\n"; my $firstLine = ; chomp $firstLine; for (1..4) { my $nextLine = ; chomp $nextLine; print "~~$firstLine~~ ", "$nextLine\n"; } process_sub_record(); } sub process_sub_record { my $sub_record = ; chomp $sub_record; for (1..4) { my $nextLine = ; chomp $nextLine; print "~~$sub_record~~ ", "$nextLine\n"; } } =PRINTS: JOB::HEREISASTRING ~~Something~~ StringA ~~Something~~ StringB ~~Something~~ StringC ~~Something~~ StringD ~~Something Else~~ StringE ~~Something Else~~ StringF ~~Something Else~~ StringG ~~Something Else~~ StringH JOB::HEREISANOTHERSTRING ~~Something~~ StringI ~~Something~~ StringJ ~~Something~~ StringK ~~Something~~ StringL ~~Something Else~~ StringM ~~Something Else~~ StringN ~~Something Else~~ StringO ~~Something Else~~ StringP =cut __DATA__ JOB::HEREISASTRING Something StringA StringB StringC StringD Something Else StringE StringF StringG StringH JOB::HEREISANOTHERSTRING Something StringI StringJ StringK StringL Something Else StringM StringN StringO StringP