Perl Tutorials -Part 82- Changing the current working direct

Posted on June 7, 2010. Filed under: Perl Tutorials |


#perl example of changing directory (chdir function)
opendir THEDIR, '.';
while ($fileName = readdir THEDIR)
{
   print "$fileName \n";
}

print "*************************\n";
#change directory to parent directory
chdir '..';
while ($fileName = readdir THEDIR)
{
   print "$fileName \n";
}

closedir THEDIR;








.
..
lock
t.pl
usr
lib
*************************

Disallowed system call: SYS_chdir
Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: