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 4054506
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T14:35:03+00:00 2026-05-20T14:35:03+00:00

after being sick for a few week I am trying to get back into

  • 0

after being sick for a few week I am trying to get back into my scripting projects and seems to be running into a newbie speed bump.

I am trying to assemble a script to slurp a file and then process parameters from the file using regex and build a hash from parameters found.

But the problem I am running into is the hash is not being constructed the way I want it, or atleast I think it is not.

Here is the tiny script I am working on.

#!/usr/bin/perl
use strict;
use warnings;
use File::Slurp;
use Data::Dumper;

my %config;

my $text = read_file("./config/settings.cfg");

if ($text =~ /^esxi\.host\s+=\s+(?<host>.+)/xm) {
    $config{host} = "$+{host}";
}

print Dumper (%config);

For those wishing to execute the script here is the config file I am building

Connection Options:
######################################################
esxi.host = server01
esxi.port = 22
esxi.username = root
esxi.password = password
######################################################

Backup Options:
#########################
Compression Options:
0 = none
1 = tar
2 = gzip
3 = tar+gzip
#########################
backup.compression = 0

Just save it to a file called settings.cfg unless you feel like changing the parameter in the script.

Anyhow this is the output I am getting from Data::Dumper.

$VAR1 = 'server01';
$VAR2 = {
          'host' => 'esxi01'
        };

What I am trying to do is make server01 the root key of the hash and host a subkey because I will also have subkeys for user, password, and port number.

I have been chewing on this for about a half hour (partly distracted) trying to figure out why it is not working, any help would be most appreciated.

  • 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-20T14:35:03+00:00Added an answer on May 20, 2026 at 2:35 pm

    Are you wanting output like this?

    $VAR1 = {
          'server01' => {
                          'host' => 'esxi01'
                        }
        };
    

    If so, your %config is fine. Your problem is you’re passing a hash (which gets interpreted as an array a list) rather than a hashref to Dumper. Try Dumper(\%config) instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the UIImageViews to make copies of themselves after being dragged
I'm trying to write a decorator that 'refreshes' after being called, but where the
I am trying to display data after being submitted with ajax. The ajax works
The data was inserted into the database after being escaped as follows: $caller=htmlentities($formVarsI['caller'], ENT_QUOTES,
In my project I am trying to save video to the iPhone after being
I'm trying out sharp-architecture (and ASP.NET MVC) for a new project after being on
How can I get the extension of compressed file after being compressed with System.IO.Compression.GZipStream
I'm sick to my back teeth with this whole provisioning business. After Xcode (4.4.1)
I'm returning to c++ after being away for a bit and trying to dust
Can someone explain to me how Hash tags get anchors after being posted. I

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.