#!/usr/bin/perl # use strict; use warnings; use diagnostics; my $control_file = 'process.txt'; # Opening the status files: print "In openControls\n open $control_file\n"; open my $control_fh, '<', $control_file or die "\nUnable to open [$control_file] file for reading: $!\n\n"; print "control_fh is opened and ready\n"; my %process_control; while ( <$control_fh> ) { chomp; my ( $key, $row ) = split /\|/; $process_control{ $key } = $row; } print "Print Process Control hash\n"; while ( my ( $control, $process ) = each %process_control ) { print "[$control], [$process]\n"; } my @list1 = qw/ a1z a2x b3y b4w c5u c6t d7s d8r e0q e1p f2o f3m i4n i5l k6k /; my @list2 = qw/ c5u b3y e1p c6t f3m a1z k6k i4n e0q f2o b4w d7s i5l a2x d8r xyz /; for my $test ( [ 1, @list1 ], [ 2, @list2 ], [ 3, ' ' ] ) { my $number = shift @$test; print "TEST list $number #####################\n"; for my $key ( @$test ) { print "Look for control [$key] - "; my $process = exists $process_control{ $key } ? $process_control{ $key } : print "WARNING [$key] was not found. - "; print "\$process_control{ $key } returned process [$process]\n"; } } # Close the status file: print "In closeControls\n close $control_file\n"; close $control_fh;