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

  • Home
  • SEARCH
  • 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

Using Rails 3.0, I have a small bit of code that I seem to
I seem to have an app on my Dev server that has lots of
I always seem to have a hard time starting a new Firefox extension. Can
I've got a small issue with Derobin's implementation of WMD editor. It doesn't seem
I have a small command line app that uses the Oracle client (specifically, Oracle.DataAccess).
I have a small ncurse program I'm running, but the output doesn't seem to
I have a small requirement and that is as follows: I have a login
I am working on a small application that is meant to call some (really
I seem to have a problem with this SQL query: SELECT * FROM appts
Most mature C++ projects seem to have an own reflection and attribute system ,

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.