in reply to how to su in a script ?

The usual mechanism for elevating privilege in UNIX is to make the program setuid (also known as suid). There are a lot of security issues with this. Consult perlsec for information.