- Perl - Home
- Perl - Introduction
- Perl - Environment
- Perl - Syntax Overview
- Perl - Data Types
- Perl - Variables
- Perl - Scalars
- Perl - Arrays
- Perl - Hashes
- Perl - IF...ELSE
- Perl - Loops
- Perl - Operators
- Perl - Date & Time
- Perl - Subroutines
- Perl - References
- Perl - Formats
- Perl - File I/O
- Perl - Directories
- Perl - Error Handling
- Perl - Special Variables
- Perl - Coding Standard
- Perl - Regular Expressions
- Perl - Sending Email
- Perl - Socket Programming
- Perl - Object Oriented
- Perl - Database Access
- Perl - CGI Programming
- Perl - Packages & Modules
- Perl - Process Management
- Perl - Embedded Documentation
- Perl - Functions References
- Perl Useful Resources
- Perl - Questions and Answers
- Perl - Quick Guide
- Perl - Cheatsheet
- Perl - Useful Resources
- Perl - Discussion
Selected Reading
Perl opendir Function
Description
This function opens the directory EXPR, associating it with DIRHANDLE for processing, using the readdir function.
Syntax
Following is the simple syntax for this function −
opendir DIRHANDLE, EXPR
Return Value
This function returns true if successful.
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w
$dirname = "/tmp";
opendir ( DIR, $dirname ) || die "Error in opening dir $dirname\n";
while( ($filename = readdir(DIR))) {
print("$filename\n");
}
closedir(DIR);
When above code is executed, it produces the following result −
. .. testdir
perl_function_references.htm
Advertisements