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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:20:20+00:00 2026-05-22T16:20:20+00:00

Why does this statement, if (! $ssh_options{user}) { delete $ssh_options{user}; } return true, but

  • 0

Why does this statement,

    if (! $ssh_options{user}) {

    delete $ssh_options{user};

}

return true, but this statement

    if ($ssh_options{user} eq 'undef') {

    delete $ssh_options{user};

}

give me the error,

Use of uninitialized value $ssh_options{"user"} in string eq at analyze.pl line 230.

I thought you always had to have something for perl to compare the value of the variable being compared.

** Update **

@ Quick Joe Smith

I cannot base my comparison on whether the hash keys exist or not because the values for this hash

sub ssh_connect {

my $host = shift;

my %ssh_options = (

    port => shift,
    user => shift,
    password => shift

    );

Come from this function which calls the sub routine

        if ((exists $config_file{user}) && (exists $config_file{password})) {

        my $vmware_user = $config_file{user};

        my $vmware_password = $config_file{password};

        ssh_connect($vmware_host, $vmware_port, $vmware_user, $vmware_password);

    } else {

        ssh_connect($vmware_host, $vmware_port);

    }
  • 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-22T16:20:21+00:00Added an answer on May 22, 2026 at 4:20 pm

    Perl hash slots have a number of ways they can be false. If the key has never been filled, the exists function will return false. If the key exists but contains an undefined value, exists will be true but the defined function will return false. In normal boolean context, as given by an if statement, a hash key that was never filled, or is undefined, '', 0 or anything that reduces to those will be false.

    From your update, it sounds like what you want is to use defined

    delete $ssh_options{user} unless defined $ssh_options{user};
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use find_or_create_by, but this statement does NOT work. It does not
All are from this post . What does these statement mean: error(nargchk(5, 6, nargin));
Does anyone have any idea what is wrong with this create statement for mysql?
As I am a MySQL newbie. What does PARTITION mean in this MySQL statement?
Does this pattern: setTimeout(function(){ // do stuff }, 0); Actually return control to the
Why does this javascript return 108 instead of 2008? it gets the day and
What does this statement meaning, could somebody elaborate me on this please (@diplomaPercentage is
Where does this statement go? Do I put it in my constructor or do
Why does this statement work with OnKeyPress event of Javascript in C#. txtPassword.Attributes.Add(OnKeyUp, CheckPasswordStrength(\
How does this if statement read out loud? if (!$_SESSION['stuff']) { $age=12; } (Admin,

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.