#! perl.exe use strict; use warnings; use XML::Simple; use Data::Dumper; my ($config, $head); unless ($head = $ARGV[0]) { my $str = "Usage: $0 name"; my $line = "-" x length($str); print "\n"; print "$str\n"; print "$line\n"; print "\n"; print "Setting Header as Unknown\n"; $head = "Unknown"; } my $file = "./Test.xml"; my $xs1 = XML::Simple->new(); unless ($config = $xs1->XMLin($file, forcearray => 1)) { print "Could NOT read $file IN:$!\n"; exit(); } my $hashrc = 0; print "\n"; #So I can see the structure while testing print Dumper($config); print "\n=======================================================\n"; print "Header = $head\n"; foreach my $key (keys (%{$config->{header}})) { my $tempkey = $config->{header}->{$key}->{'name'} . $key; print "\nTesting \$tempkey = $tempkey\n"; if ("$head" eq $config->{header}->{$key}->{'name'} . $key) { $hashrc = 1; foreach my $mapping (@{$config->{header}->{$head}->{act}}) { print "\$mapping = $mapping\n"; } last; } } unless ($hashrc) { print "$head is not currently mapped\n"; }