PerlIO::via::Limit - PerlIO layer for length restrictions
use PerlIO::via::Limit; PerlIO::via::Limit->length(20); # - or - use PerlIO::via::Limit length => 20; # reading open( my $fh, "<:via(Limit)", $file ); # writing open( my $fh, ">:via(Limit)", $file );
PerlIO::via::Limit implements a PerlIO layer that restricts length of stream.
Limit length of stream. Default is undef that means unlimited.
If set true value, an exception will be occurred when stream reaches limit of length. Default is false.
use PerlIO::via::Limit sensitive => 1; open( my $in, "<:via(Limit)", $file ) or die; eval { while( <$in> ){ # do something... } };if( $@ ){ # "$in is trying to read exceeding the limit." warn "$@"; } close $in or die;
Note that the $@ is a Exception::Class object.
When the exception is thrown by sensitive option, the buffer for reading does not be filled.
PerlIO::via
Exception::Class
PerlIO::via::Limit is hosted on github https://github.com/hiroaki/PerlIO-via-Limit
WATANABE Hiroaki <hwat@cpan.org>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install PerlIO::via::Limit, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlIO::via::Limit
CPAN shell
perl -MCPAN -e shell install PerlIO::via::Limit
For more information on module installation, please visit the detailed CPAN module installation guide.