#!/usr/bin/env perl use strict; use warnings; use autodie; my $config_file = 'pm_1056046_parse_config.txt'; my $gen = 'parent'; my %cfg; { local $/ = "DEPLOYED\n"; open my $config_fh, '<', $config_file; while (<$config_fh>) { $gen = 'child' if /CHILD CONFIG/; /(\w+)\s+HOLDS\s+(\w+)/; $cfg{$gen}{$1}{holds} = $2 if $gen eq 'child'; push @{$cfg{parent}{$1}{equals}} => /(total_\w+)/g if $gen eq 'parent'; } close $config_fh; } for (keys %{$cfg{child}}) { print "$_ : @{$cfg{parent}{$cfg{child}{$_}{holds}}{equals}}\n"; } #### $ pm_1056046_parse_config.pl first_distribution : total_finish total_cancel second_distribution : total_cancel third_distribution : total_finish total_cancel forth_distribution : total_dist total_finish total_cancel