in reply to Re: Re: Re: Problem with ascertaining last NT logon - Roth script
in thread Problem with ascertaining last NT logon - Roth script

That's great! -other than what I presume was a typo,
foreach my $Machine ( sort keys %Result ) { my $MachineInfo = $Results{$Machine}; foreach my $Account ( sort keys %{$MachineInfo} )
should be my $MachineInfo = $Result{Machine}??

The output now produces an entry for each machine in the list. All I have to do now is compare the two entries and get it to spit out the last value in each field from all servers, but I can do that with what you've given me.

Thanks!

  • Comment on Re: Re: Re: Re: Problem with ascertaining last NT logon - Roth script
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Problem with ascertaining last NT logon - Roth script
by Roger (Parson) on Feb 17, 2004 at 10:04 UTC
    No, it's not a typo. :-)

    $Machine is a variable that gets populated with a different key from the hash (in sorted order) for each iteration of the outer for loop.

      It would continually return the same value if you used a literal like Machine instead of $Machine.

      It is very rare that a programmer would hardcode hash values like that. There are uses for it (mainly learning about hashes), but typically its done by reading data from another source to populate a hash for a (sometimes predefined) set of keys.

      Running the command: perldoc perldata from your command_line/terminal should help you get more acquainted with hashes. Also just write some test hash scripts to learn more about the behavior of hashes. You'll always learn more by writing test scripts, and experiencing the behavior first hand.


      Grygonos

        oops, ok, I'll change the variable back to the correct name.
        UPDATE: I changed my $MachineInfo = $Result{$Machine}; back to $Results, with the ahem, result that $MachineInfo remains undef for the duration of the script. I can't see where $Results is defined...

        And yes, you're right about just *doing* some test scripts, Grygonos, but I was really just hoping to get this particular script running out of the box for a task I need to do nearly every day...

        I'll definitely check out the perldoc