choedebeck has asked for the wisdom of the Perl Monks concerning the following question:

In following up String format question I came up with the following solution
my $VAR1; eval(Dumper($password)); $ssh->login($username, $VAR1);
While this serves my purpose, I would really like to know why I cannot pass something to the ssh object that I get from a GUI without erroring. Anyone have any ideas?

Replies are listed 'Best First'.
Re: Follow up: String Formatting
by ikegami (Patriarch) on Dec 05, 2005 at 21:05 UTC
    Why don't you provide the output of:
    sub hex_dump { return join ' ', map { sprintf('%02X', ord($_)) } split //, (@_ ? $_[0] : $_); } print('password: ', hex_dump($password), "\n"); print('VAR1: ', hex_dump($VAR1 ), "\n");

    Update: Added missing ord.

      The hex dumps are identical. The only thing I can think of it the Net::SSH::Perl module doesn't like anything else having a reference to any variable you pass in to it. Anyone else have any ideas?
        The hex dumps are identical.
        Would you post them so we can see?

        Caution: Contents may have been coded under pressure.
Re: Follow up: String Formatting
by Roy Johnson (Monsignor) on Dec 05, 2005 at 21:33 UTC
    Seems to me that if it was a question of reference counts, you could achieve the same thing with
    $ssh->login($username, "$password");
    Does that work?

    Caution: Contents may have been coded under pressure.
      I guess it is not a question of reference counts then. I have tried the following
      $ssh->login($username, "$password");
      and
      my $newpass = $password; $ssh->login($username, $newpass);
      and
      $ssh->login($username, scalar($password));
      All to no avail. The only thing that has worked is either me hardcoding the password into my script or me using the Data::Dumper technique.