« Object Relation Mapping (ORM) | Main | Melksham Art Cafe »
June 09, 2007
Perl - functions for directory handling
Perl has many built in functions for file and directory handling and you should use them in preference to shelling out in your scripts because:
• They work across operating systems (at least as far as is practical)
• They are much more efficient as there's no extra processes being started and stopped all the time.
I've added a source code sample to our web site which shows some of these in use ...
cwd to find out where you are
chdir to change your current directory
-d to check is a symbol is a directory
opendir and readdir to read through a directory's content
Sample output:
earth-wind-and-fire:~ grahamellis$ perl chdirddemo
We are in /Users/grahamellis
We are now in /Users/grahamellis/jun07
Directory entry count: 24
We are now in /Users/grahamellis
Directory entry count: 390
earth-wind-and-fire:~ grahamellis$
Posted by gje at June 9, 2007 07:48 AM