in reply to Trouble with net use

At the start of any program, you should include use strict; use warnings;. This combo will catch a large number of bugs, including what you are hitting. You will need to declare all variables with my in order to satisfy strict, but it in turn catches a large number of typos.

Running this with warnings returns a series of "Useless use of a constant in void context". This is because you have used single quotes (') where you probably meant to use backticks (`).

Update: I should also mention, in addition to codeacrobat's note about chomp, that you need to escape $ as well as \ in interpolated strings - you unintentionally reference the $\ variable twice in your code. Warnings will catch that one, too.