in reply to Grabbing tokens

A simpler option may be backticks
my $res = (split ' ', `net use J\: \\\\$hostname\\c\$`)[2];
See. `STRING` under Regexp Quote-Like Operators in perlop for more info.
HTH

_________
broquaint