http://www.perlmonks.org?node_id=349460


in reply to Remote Drive Info

There are a few problems here.
  1. Your foreach loop uses $DISK to store each item, then you go and access $Disk. Perl is case-sensitive, either change the first to $Disk or change the rest to $DISK
  2. $Disk->{Size} and $Disk->{FreeSpace} seem to be returning undef, so those 2 columns of your output are blank as well.
  3. You have 4 format fields in your DISK_FORMAT and 5 variables below it. Not sure if you want another field, or if you want to get rid of a variable there.
  4. Again, in your FormatNumber sub, you work on $Number, but return $NUMBER.
Other than those 3, the code seems to work fine, although there are other small problems such as formatting, and the use of local that could use fixing up.

Update: Spotted the error in FormatNumber

Replies are listed 'Best First'.
Re: Re: Remote Drive Info
by Util (Priest) on Apr 30, 2004 at 17:49 UTC
    ++Paladin. I would just add:
    • By adding either #!perl -w or use warnings 'all'; to the top of your program, you would receive diagnostic messages that would have helped you find the problem; i.e.
      Name "main::NUMBER" used only once: possible typo at line 47
      Name "main::DISK"   used only once: possible typo at line 31
      Don't forget also use strict!

      ronald