Tutorials Point


  Perl Home

  PERL Functions

© 2013 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL opendir Function



Advertisements

Syntax

opendir DIRHANDLE, EXPR


Definition and Usage

Opens the directory EXPR, associating it with DIRHANDLE for processing, using the readdir function

Return Value

  • 0 on failure

  • 0 on failure

Example

Try out following example:

#!/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);

It will produce following results:

.
..
testdir


Advertisements


  

Advertisements