- 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 readline Function
Description
This function reads a line from the filehandle referred to by EXPR, returning the result. If you want to use a FILEHANDLE directly, it must be passed as a typeglob.
Simply readline function is equvivalent to <>.
Syntax
Following is the simple syntax for this function −
readline EXPR
Return Value
This function returns only one line in a scalar context and in a list context, a list of line up to end-of-file is returned
Example
Following is the example code showing its basic usage −
#!/usr/bin/perl -w my($buffer) = ""; open(FILE, "/etc/services") or die("Error reading file, stopped"); $buffer = <FILE>; print("$buffer"); $buffer = readline( *FILE ); print("$buffer"); close(FILE);
When above code is executed, it produces the following result −
# /etc/services: # $Id: services,v 1.33 2003/03/14 16:41:47 notting Exp $
perl_function_references.htm
Advertisements