Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

. And .. whilst opening a directory

Status
Not open for further replies.

chrismassey

Programmer
Aug 24, 2007
264
GB
When I view the contents of a directory, why is it that the first values are . and .. before printing the actual contents. This isn't necessarily a problem because I have used shift to remove the first and second elements of the array which are . and ..

Chris
 
they have nothing to do with perl if thats what you may have thought. I think '..' points up one directory level, not sure what '.' is for though.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
. is the current directory
if you don't have your profile setup right you need to say
./script.pl
instead of saying script.pl because just saying script.pl tells it to look in your path and if . is not in your path it will never find it.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
@Files=grep(!/^\.\.?$/, readdir DIRHANDLE);

reads the filenames into an array and eliminates . and ..

PS to Kev... : from 24 hours

_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top