PerlIO::fgets - Provides a fgets() like function for PerlIO file handles
fgets()
$octets = fgets(STDIN, 1024); $octets = fgets(*STDIN, 1024); $octets = fgets(\*STDIN, 1024); while ( ! eof($fh) ) { defined( $_ = fgets($fh, 1024) ) or die "fgets failed: $!"; ... }
Provides a fgets() like function for PerlIO file handles
Attempts to read a line from the given file handle $fh.
$fh
Usage
$octets = fgets($fh, $maximum);
Arguments
The file handle to read from. Must be a PerlIO file handle.
$maximum
A positive integer containing the maximum number of octets to be read from the file handle (including the trailing newline character).
Returns
If fgets encounters end-of-file before a newline or $maximum octets read before a newline, it returns the octets. If fgets reaches end-of-file before reading any octets, it returns an empty string. If unsuccessful, fgets returns undef and $! contains the I/O error.
fgets
undef
$!
Note
Unlike stdio's fgets(), this implementation is not sensitive to input containing null characters.
Current implementation has no understanding of Unicode (UTF-X), only octets.
In addition to Run-Time:
Please report any bugs or feature requests to bug-perlio-fgets@rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PerlIO-fgets
bug-perlio-fgets@rt.cpan.org
Christian Hansen chansen@cpan.org
chansen@cpan.org
Copyright 2010 by Christian Hansen.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PerlIO::fgets, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlIO::fgets
CPAN shell
perl -MCPAN -e shell install PerlIO::fgets
For more information on module installation, please visit the detailed CPAN module installation guide.