Input XML file:- lpass M8960AAAAANAAL1004 \\TEST\M9650AAAAANAAL1004\ lpass_proc rpm M8960AAAAANAAR1004 \\TEST\M9650AAAAANAAR1004\ rpm_proc rpm.mbn rpm_proc/ wcnss M8960AAAAANAAW1004 \\TEST\M9650AAAAANAAW1004\ wcnss_proc OUTPUT should be:- PASS_BUILD_ROOT \\TEST\M9650AAAAANAAL1004 PM_BUILD_ROOT \\TEST\M9650AAAAANAAR1004 NSS_BUILD_ROOT \\TEST\M9650AAAAANAAW1004 CURRENT CODE:- use strict; use warnings; use Getopt::Long; use File::Glob (); my %options=(); GetOptions (\%options,'loc=s'); #print "\n$options{loc}"; my $contents_xml = glob(($options{loc} . '\\contents.xml')); #print "\n$contents_xml";