Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6933867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:53:15+00:00 2026-05-27T11:53:15+00:00

I have some xml files in a directory , so I am searching required

  • 0

I have some xml files in a directory , so I am searching required xml files in that directory and storing xml data in a hash data structure using below script. But my problem is I need to save the file path of each xml file in the hash But Can any one help me how to save file path in hash data
I written script like this

#!/usr/bin/perl
use warnings;
use strict;
use XML::Simple;
use Carp;
 use File::Find;
use File::Spec::Functions qw( canonpath );  
use Data::Dumper;

my @ARGV ="C:/Main/work"; die "Need directories\n" unless @ARGV;
 find(
 sub {
    return unless ( /(_service\.xml)$/ and -f );
    Hash_information();
    return;
},
@ARGV
);

sub Hash_information {
my $path= $_;

my $xml = new XML::Simple;
my $data = $xml->XMLin("$path", ForceArray => [  
'Service','SystemReaction','SW','HW','Component' , 'BM'],
                             KeyAttr=>{Service=>'Id'}  );
   print Dumper ($data);
 return;
  }

using above script I am getting all service xml files form folder and using XML::Simple storing in a hash data structure. Now I want to save file path of each xml file in the hash data structure. Can any one help me.
Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:53:15+00:00Added an answer on May 27, 2026 at 11:53 am

    In the subroutine for File::Find, $File::Find::name is the complete path name. Pass that to your Hash_information subroutine.

    ...
    find(
        sub {
            return unless ( /(_service\.xml)$/ and -f );
            Hash_information($File::Find::name);
    ...
    sub Hash_information {
    my ($path) = @_;
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some xml files that contain text, which are displayed on my website.
I have some xml data contained in three files (Database.xml, Participants.xml, and ConditionTokens.xml). I
I have some files in the same directory (in UNIX filesystem) that looks like:
I have an application that needs to copy some files to a directory under
I have an ant build system. I have some common build files (common.xml) that
I have a class library that uses some xml files found in its own
I have some XML files which are used to generate my webpages, however I
Do you have some predefined set of targets which all build.xml files you create
I have some php files in a server which generate xml code in them.
I'm defining a style XML for my android app. I have some TTF files

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.