in reply to Re: randomly choosing an alphabetic letter
in thread randomly choosing an alphabetic letter

Hello,

If I would like to choose 4 free drives, and I run the Win32::GetNextAvailDrive() 4 times, it gives me the same drive everytime, not different ones.

Is there a way I can find out more than one available drive?

Thanks

  • Comment on Re^2: randomly choosing an alphabetic letter

Replies are listed 'Best First'.
Re^3: randomly choosing an alphabetic letter
by Tanktalus (Canon) on Mar 16, 2005 at 01:15 UTC

    What you would want to do, then, is use each one in a loop, rather than getting them ahead of time. That is, rather than:

    my @drives = ( Win32::GetNextAvailDrive(), Win32::GetNextAvailDrive(), Win32::GetNextAvailDrive(), Win32::GetNextAvailDrive(), ); do_stuff_with(@drives);
    do this:
    for (1..4) { my $drive = Win32::GetNextAvailDrive(); do_stuff_with($drive); }
    Hopefully, do_stuff_with() will net use or something so that the drive becomes unavailable (in use) so the next time through, Win32::GetNextAvailDrive will get a new drive.