- 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
Mohd Mohtashim has Published 251 Articles
Mohd Mohtashim
393 Views
You can test certain features very quickly within Perl using a series of test operators known collectively as -X tests. For example, to perform a quick test of the various permissions on a file, you might use a script like this −#/usr/bin/perl my $file = "/usr/test/file1.txt"; my (@description, $size); if ... Read More
Mohd Mohtashim
192 Views
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 FunctionThe first requirement is to find your position within a file, which you do using the tell function −tell FILEHANDLE tellThis returns the position ... Read More
Mohd Mohtashim
1K+ Views
Here is the Perl example, which opens an existing file file1.txt and read it line by line and generate another copy file file2.txt.#!/usr/bin/perl # Open file to read open(DATA1, "file2.txt"); # Copy data from one file to another. while() { print DATA2 $_; } close( DATA1 ); close( DATA2 ... Read More
Mohd Mohtashim
660 Views
Once you have an open file handle in Perl, you need to be able to read and write information. There are a number of different ways of reading and writing data into the file.The OperatorThe main method of reading the information from an open filehandle is the operator. ... Read More
Mohd Mohtashim
3K+ Views
There are following two functions with multiple forms, which can be used to open any new or existing file in Perl.open FILEHANDLE, EXPR open FILEHANDLE sysopen FILEHANDLE, FILENAME, MODE, PERMS sysopen FILEHANDLE, FILENAME, MODEHere FILEHANDLE is the file handle returned by the open function and EXPR is the expression having ... Read More
Mohd Mohtashim
127 Views
While $^ or $FORMAT_TOP_NAME contains the name of the current header format in Perl, there is no corresponding mechanism to automatically do the same thing for a footer. If you have a fixed-size footer, you can get footers by checking variable $- or $FORMAT_LINES_LEFT before each write() and print the ... Read More
Mohd Mohtashim
148 Views
What about if your report is taking more than one page? You have a good solution in Perl to create pagination. We simply use $% or $FORMAT_PAGE_NUMBER variable along with header as follows −format EMPLOYEE_TOP = =================================== Name Age Page @< $% ... Read More
Mohd Mohtashim
207 Views
Sometime you would be interested in adding a header to your report. This header will be printed on top of each page. It is very simple to do this using Perl. Apart from defining a template you would have to define a header and assign it to $^ or $FORMAT_TOP_NAME ... Read More
Mohd Mohtashim
135 Views
In order to invoke a format declaration in Perl Script, we would use the write keyword −write EMPLOYEE;The problem is that the format name is usually the name of an open file handle, and the write statement will send the output to this file handle. As we want the data sent to ... Read More
Mohd Mohtashim
72 Views
Perl uses a writing template called a 'format' to output reports. To use the format feature of Perl, you have to define a format first and then you can use that format to write formatted data.SyntaxFollowing is the syntax to define a Perl format −format FormatName = fieldline value_one, value_two, ... Read More