I have an existing script to automate password resets for a passel o' Cisco switches.   The following snippet is my attempt at having the script prompt for old+new passwords (instead of having them coded in the script's config parameters).

But it doesn't work.  
Looks like keyboard-entered passwords aren't getting pushed(?) into the scalars.   Multiple "uninitialized value" errors result for each of lines 8, 21, 26.

Would any clueful Monks care to enlighten me on whatever fundamental concept/syntax I'm lacking?
    cheers,
    Don
    striving for Perl Adept

1 #!/usr/bin/perl -w 2 # getpass.pl 3 4 use Term::ReadKey; 5 use Tie::IxHash; 6 use vars qw($key $t %passwds); 7 8 $t = tie(%passwds, Tie::IxHash, 9 'Enter old password:' => "$oldpass", 10 'Enter old enable password:' => "$oldenable", 11 'Enter new password:' => "$newpass", 12 'Confirm new password:' => "$newpassConf", 13 'Enter new enable password:' => "$newenable", 14 'Confirm new enable password:' => "$newenableConf", 15 ); 16 17 print "Prompting for passwords (won't appear on-screen)\n"; 18 foreach $prompt (keys (%passwds)) { 19 print "$prompt "; 20 ReadMode('noecho'); 21 chomp($prompt{$key} = <STDIN>); 22 ReadMode(0); 23 print "\n" 24 } 25 26 unless (("$newpass" eq "$newpassConf") and ("$newenable" eq "$ne +wenableConf")) 27 {die "\nNew password(s) confirmation didn't match. Tough be +ans. Try again.\n"}

In reply to Scalars as hash keys? by ybiC

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.