--- name: readline status: documented runtime: pp source: src/runtime/pp/io.rs --- ```{index} single: readline; Perl built-in (pp runtime) ``` # readline ## Synopsis ```perl $line = <$fh>; # scalar: next line @lines = <$fh>; # list: all remaining lines $line = readline($fh); # explicit function form ``` ## Description PP function for readline Reads one or more records from a filehandle. In scalar context, returns the next record from the filehandle (including the record separator, typically a newline). Returns `undef` at end-of-file. In list context, returns all remaining records. The record separator is controlled by `$/`: - `"\n"` (default) -- line-at-a-time mode - `""` -- paragraph mode (reads until a blank line) - `undef` -- slurp mode (reads the entire file) - `\N` (reference to integer) -- fixed-length record mode (reads N bytes) - arbitrary string -- reads until that separator is found When the STACKED flag is set, the result is assigned to the lvalue target on the stack (e.g. `my $line = <$fh>`). Supports both lexical (`$fh`) and bareword (`FH`) filehandles, as well as IO::Handle / IO::File objects. ## See also eof, read, getc, chomp