I am somehow puzzled why you want to use CGI to do command-line processing. Nevertheless CGI scripts can run as normal programs. You will need to drop the question mark before uid. Otherwise user1 is treated as the value of the "?uid" variable.
use strict;
use CGI;
my $q = new CGI;
my $q_uid = $q->param('uid');
print "$q_uid\n";