- Perl Basics
- 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 Advanced
- 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 - Useful Resources
- Perl - Discussion
Perl telldir Function
Description
This function returns the current position of read pointer within the directory listing referred to by DIRHANDLE. This returned value can be used by seekdir() function.
Syntax
Following is the simple syntax for this function −
telldir DIRHANDLE
Return Value
This function returns the current position within the directory.
Example
Following is the example code showing its basic usage, we have only two files in /tmp directory −
#!/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);
When above code is executed, it produces the following result −
Position without read : 0 Position after one read : 1 .ICE-unix .ICE-unix Position after second read : 1
perl_function_references.htm
Advertisements