IO::Unread - push more than one character back onto a filehandle
use IO::Unread; unread STDIN, "hello world\n"; $_ = "goodbye"; unread ARGV;
IO::Unread exports one function, unread, which will push data back onto a filehandle. Any amount of data can be pushed: if your perl is built with PerlIO layers, the data is stored in a special :pending layer; if not, the module ties the filehandle to a class which returns the unread data and unties itself.
IO::Unread
unread
:pending
tie
unread unreads LIST onto FILEHANDLE. If LIST is omitted, $_ is unread. Returns the number of characters unread on success, undef on failure. Warnings are produced under category io.
$_
undef
io
Note that unread $FH, 'a', 'b' is equivalent to
unread $FH, 'a', 'b'
unread $FH, 'a'; unread $FH, 'b';
, ie. to unread $FH, 'ba' rather than unread $FH, 'ab'.
unread $FH, 'ba'
unread $FH, 'ab'
ungetc pushes the first character of STRING onto FILEHANDLE. Unlike unread, it does not use a tie implementation if your perl doesn't support PerlIO layers; rather it calls your ungetc(3). This is only guarenteed to support one character of pushback, and then only if it is the last character that was read from the handle.
ungetc
None by default; unread, ungetc on request.
ungetc is subject to the whims of your libc if you're not using perlio.
Copyright 2003 Ben Morrow <ben@morrow.me.uk>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
PerlIO, perltie, ungetc(3)
To install IO::Unread, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IO::Unread
CPAN shell
perl -MCPAN -e shell install IO::Unread
For more information on module installation, please visit the detailed CPAN module installation guide.