- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Positioning inside a File in Perl
You can use to tell function in Perl to know the current position of a file and seek function to point a particular position inside the file.
Perl tell Function
The first requirement is to find your position within a file, which you do using the tell function −
tell FILEHANDLE tell
This returns the position of the file pointer, in bytes, within FILEHANDLE if specified, or the current default selected filehandle if none is specified.
Perl seek Function
The seek function positions the file pointer to the specified number of bytes within a file −
seek FILEHANDLE, POSITION, WHENCE
The function uses the fseek system function, and you have the same ability to position relative to three different points: the start, the end, and the current position. You do this by specifying a value for WHENCE.
Zero sets the positioning relative to the start of the file. For example, the line sets the file pointer to the 256th byte in the file.
seek DATA, 256, 0;
- Related Articles
- Perl File Extension
- Getting File Information in Perl
- How to check if a file exists in Perl?
- Raise a "File Download" Dialog Box using Perl
- How to delete a string inside a file(.txt) in java?
- How to search a value inside a JSON file using Jackson in Java?
- Absolute Positioning in CSS
- Static Positioning in CSS
- Relative Positioning in CSS
- Fixed Positioning in CSS
- How to read a single file inside a zip archive with PHP
- Getting root permissions on a file inside of vi on Linux
- CSS Positioning Elements
- Relative Positioning Working in CSS
- CSS positioning related properties
