in reply to Changing user in perl script
Better use su, su is more common (sudo is absent on many Unixen), and su runs using the target user password (sudo uses the source user password by default, so you'll have to tweak the /etc/sudoers file to get what you want).