Tutorials Point


  Perl Home

  PERL Functions

© 2011 TutorialsPoint.COM


  Home     References     About TP     Advertising  

PERL seekdir Function



Syntax

seekdir DIRHANDLE, POS


Definition and Usage

Sets the current position within DIRHANDLE to POS. The value of POS must be a value previously returned by telldir.

seekdir() function is similar to Unix seekdir() system call.

Return Value

  • 0 on failure

  • 1 on success

Example

Create one directory testdir inside /tmp and Try out following example:

#!/usr/bin/perl -w

opendir(DIR, "/tmp");

print("Position without read : ", telldir(DIR), "\n");

$dir = readdir(DIR);
print("Position after one read : ", telldir(DIR), "\n");
print "$dir\n";
seekdir(DIR,0);

$dir = readdir(DIR);
print "$dir\n";
print("Position after second read : " , telldir(DIR), "\n");

closedir(DIR);

It will produce following results:

Position without read : 0
Position after one read : 1220443271
test.txt
test.txt
Position after second read : 1220443271


Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names