The first thing I noticed was the wrong shebang/hashbang line, it should be #!/usr/bin/perl , but since you are running your script on Windows, it is ignored anyway.
Regarding your issue with output redirection, I suggest to try this:
print `net user %USERNAME% /domain >out.txt`;
Let me know if that worked.
Regarding the extraction part, I suggest doing it in Perl on-the-fly, without redirecting it to outfile first.
If you need help with this, you'll need to post a full sample output of the mentioned net user command.