Here is an example of how you would use the chdir function in PERL:
#First, we open our main directory
opendir(DIR,'test');
#Then we navigate to a subdirectory
chdir 'subtest';
#Now we would be in the 'subtest' folder or directory
#We can navigate back up to the 'test' folder or directory
chdir '..';
The ".." in above example tells PERL to navigate to the folder or directory directly above our current folder or directory.