#!perl use strict; use warnings; use IPC::System::Simple qw/capture/; my $destination = "\\\\BLAH\\NESTED\\OBFUSCATED\.WITH SPECIAL_CHARS\\SHARE\\NAME\\DOWN\\DEEP"; print netUse($destination); sub netUse { my $path = shift; my $cmd = "net use * $path"; my ($msg) = grep /Drive/, capture($cmd); return ($msg =~ /Drive (.*) is now connected/); }