Use the special variable $<
So with the code:
$username = getpwuid($<);
You can get the unix username running the script.