People keep getting tasks to write a Perl script that can change directory that even after exiting the Perl script the change will persist.

You cannot do that. Not in Perl and not in any other programming language, except the language of the current shell.

However, if you would like to change the directory for the rest of your script and maybe even for external programs that you launch from your script, then it is quite easy.