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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:43:29+00:00 2026-05-18T19:43:29+00:00

I seem to have a small issue with my script where I need to

  • 0

I seem to have a small issue with my script where I need to call “tied” against a sub routine that is earlier in the the script so that I can access the functions that are related to the object that the hash is tied to. The problem is when I go to run the script it return the error “Can’t call method “SetWriteMode” on unblessed reference at cbc_encrypt_test.pl line 30.” At first I had no idea what it was talking about, I think the problem is due to me using a reference to point back at the subroutine which return the hash reference in the first place. Because as far I understand “config_file = \%cfg” in this case. After looking at perldoc about perlref’s I am still lost. I read over the document pretty well and did not see anything about referencing subroutines in the way I need to.

Here the entire script so far.

#!/usr/bin/perl

use strict;

use warnings;

use Term::ANSIColor;

use Config::IniFiles;

use Crypt::CBC;

start_script();



sub start_script {

    system ("clear");

    encrypt_password();

} # end start_script

sub config_file {

    my $cfg_file = 'settings.ini';

    my %cfg;

    tie %cfg, 'Config::IniFiles', ( -file => "$cfg_file" );

    return \%cfg;

} # end config_file

sub encrypt_password {
    my $password = config_file()->{ESX}{password};
    my $cipher = Crypt::CBC->new( -key => 'EF1FAD9B87F8365B242669E624FEB36CDBCCFEE0096CC45DDDCF6F5995E83F61',
                    -cipher => 'Rijndael'
                    );
    my $encrypted_password = $cipher->encrypt_hex("$password");
    chomp $encrypted_password;
    config_file()->{ESX}{password} = $encrypted_password;
    tied config_file()->SetWriteMode(0666);
    tied config_file()->RewriteConfig();
    return $encrypted_password;
} # end encrypt_password
  • 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-18T19:43:30+00:00Added an answer on May 18, 2026 at 7:43 pm

    Looks like a precedence issue. Running the construct through B::Deparse shows the problem:

    $ perl -MO=Deparse,-p -e 'tied config_file()->method()'
    tied(config_file()->method);
    -e syntax OK
    

    So Perl first tries to call the method on the reference returned by config_file(), and fails because that reference is not a blessed object (like tied would return).

    Instead try:

    tied(%{config_file()})->SetWriteMode(0666);
    tied(%{config_file()})->RewriteConfig();
    

    or better yet:

    my $cfg = tied %{config_file()};
    $cfg->SetWriteMode(0666);
    $cfg->RewriteConfig();
    

    or

    for (tied %{config_file()}) {
        $_->SetWriteMode(0666);
        $_->RewriteConfig();
    }
    

    Also, depending on how Config::IniFiles is written, you may run into problems where each call to config_file() returns a new object, so the aggregate calls you make don’t apply to each other properly. You should cache the object as shown in my answer to your previous question.

    Edit: I didn’t catch the missing dereference that ysth pointed out which would have been the second problem. Fixed above.

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

Sidebar

Related Questions

I have a rather small but weird problem that I can't seem to fix.
I am running into a strange issue in perl that I can't seem to
I've run into an issue that I can't seem to figure out the solution
I have a routing issue which I can't seem to get my head around.
I have a small script that I wrote to send an email out to
I have a css issue which I can't seem to figure out. I have
Have run into an issue that i am hoping somebody can help give me
I have a small application which doesn't seem to work. Please help. Server: var
I seem to have an issue with connecting to an embedded FireBird database from
I seem to have an issue where with jQuery Grid (jqGrid) if I have

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.