- 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 tell Function
Description
This function returns the current position of read pointer (in bytes) within the specified FILEHANDLE. If FILEHANDLE is omitted, then it returns the position within the last file accessed.
Syntax
Following is the simple syntax for this function −
tell FILEHANDLE tell
Return Value
This function returns current file position in bytes.
Example
Following is the example code showing its basic usage, to check this function do the followings −
Create a text file with "this is test" as content and store it into /tmp directory.
Read 2 characters from this file.
Now check the position of read pointer in the file.
#!/usr/bin/perl -w open( FILE, "</tmp/test.txt" ) || die "Enable to open test file"; $char = getc( FILE ); print "First Character is $char\n"; $char = getc( FILE ); print "Second Character is $char\n"; # Now check the position of read pointer. $position = tell( FILE ); print "Position with in file $position\n"; close(FILE);
When above code is executed, it produces the following result −
First Character is E Second Character is O Position with in file 2
perl_function_references.htm
Advertisements