in reply to Changing user in perl script

I may be missing something here... but with both sudo and su you're going to have to deal with prompts unless the initial script is run as a superuser. How about:
#!/usr/bin/perl $|++; print "enter someuser password at the prompt below:$/"; $i=`su someuser -c "whoami"`; print $i;