Ryan Frantz wrote: > Perlers, Hello,
> I'm working on a small script that checks the free space on local fixed > drives on my system. Since there other drive types (i.e. floppy, > CD-ROM, network maps) I want to exclude those. I decided to use a hash > but the script still displays all of the drives on my system. If I just > use simple 'next' statements, it works fine. I've placed the block > inside the original foreach and even tried wrapping it around the print > statements to no avail. What gives? > > # how much pizza has been eaten? > > use warnings; > use strict; > > use Win32::OLE('in'); > > my $megaBytes = "1048576"; > my $gigaBytes = "1073741824"; > > my %ignoreDriveTypes = ( > 'floppy' => '2', > 'network' => '4', > 'cdROM' => '5', > ); > > my $sobj = > Win32::OLE->GetObject('winmgmts:{impersonationLevel=impersonate}') > or die "Unable to create server object: " . Win32::OLE->LastError() > . "\n"; > > foreach my $process (in $sobj->InstancesOf("Win32_LogicalDisk")) { > > foreach my $type ( keys %ignoreDriveTypes ) { > next if ( $process->{DriveType} == $ignoreDriveTypes{$type} ); > } Your problem is that next refers to the inner-most for loop but you want it to refer to the outer for loop so you have to use a label: OUTER: foreach my $process (in $sobj->InstancesOf("Win32_LogicalDisk")) { foreach my $type ( keys %ignoreDriveTypes ) { next OUTER if ( $process->{DriveType} == $ignoreDriveTypes{$type} ); } Or you could use a different hash structure and avoid the inner for loop: my %ignoreDriveTypes = ( 2 => 'floppy', 4 => 'network', 5 => 'cdROM', ); foreach my $process (in $sobj->InstancesOf("Win32_LogicalDisk")) { next if exists $ignoreDriveTypes{ $process->{DriveType} }; John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>