------------------------------------------------ On Tue, 9 Sep 2003 14:39:58 -0400, "Li, Kit-Wing" <[EMAIL PROTECTED]> wrote:
> This may not be the right thread but I'd like to see if someone could point > me to the right direction. I'm writing a CGI script to show current > performance of the Apache server and I'm using Linux::stat to get the disk > IO for example. I can seem to access the value of the hash reference(see > below). Does anybody have any thoughts? Is there a more generic mailing > list for the different perl modules? I know there's the mod_perl thread but > its more for Apache. Any help will be greatly appreciated. Thanks! > Some modules or subjects have a mailing list associated with them, check the documentation of the module or the "lists" list page at http://lists.perl.org. There is also the [EMAIL PROTECTED] list which seems to be a catch all and this topic would certainly not be OT for it. > use Data::VarPrint; > use Linux::stat; > > my $stat = Linux::stat->new( [ stat => "path to /proc/stat" ] ); > my $hashref = $stat->stat(); > Right here you are getting a hash reference, but... > print $hashref{'disks'}=>{'io'}; > Right here you are both accessing a regular hash and making it a list....at least I think. You don't have strict and warnings applied do you? You probably want something along the lines of $hashref->{'disks'}->[0]->{'io'} ... notice -> not => and that the reference name is immediately followed by an arrow. For those in the crowd that like the brevity: $hashref->{disks}[0]{io} should do the trick but I prefer the "This is exactly what I mean syntax." The "[0]" that I added is to specify the disk that you want to access information for, in this case the first. The 'disks' key stores an array reference as its value, with each element of the array being a different disk. So you may need to loop, or check which disk you want information on. To see the full structure of what the module returns you may want to use the Data::Dumper module, like so: print Dumper($hashref); You may also wish to consult, perldoc perlreftut perldoc perlref ...and the excellent Learning PORM book, (does anyone know, did ORA plan that, or did the JAPHs slip one past them?)... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]