⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 iterator.pm

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 PM
字号:
package TAP::Parser::Iterator;use strict;use vars qw($VERSION);use TAP::Parser::Iterator::Array   ();use TAP::Parser::Iterator::Stream  ();use TAP::Parser::Iterator::Process ();=head1 NAMETAP::Parser::Iterator - Internal TAP::Parser Iterator=head1 VERSIONVersion 3.07=cut$VERSION = '3.07';=head1 SYNOPSIS  use TAP::Parser::Iterator;  my $it = TAP::Parser::Iterator->new(\*TEST);  my $it = TAP::Parser::Iterator->new(\@array);  my $line = $it->next;Originally ripped off from L<Test::Harness>.=head1 DESCRIPTIONB<FOR INTERNAL USE ONLY!>This is a simple iterator wrapper for arrays and filehandles.=head2 Class Methods=head3 C<new> my $iter = TAP::Parser::Iterator->new( $array_reference ); my $iter = TAP::Parser::Iterator->new( $filehandle );Create an iterator.=head2 Instance Methods=head3 C<next> while ( my $item = $iter->next ) { ... }Iterate through it, of course.=head3 C<next_raw> while ( my $item = $iter->next_raw ) { ... }Iterate raw input without applying any fixes for quirky input syntax.=cutsub new {    my ( $proto, $thing ) = @_;    my $ref = ref $thing;    if ( $ref eq 'GLOB' || $ref eq 'IO::Handle' ) {        return TAP::Parser::Iterator::Stream->new($thing);    }    elsif ( $ref eq 'ARRAY' ) {        return TAP::Parser::Iterator::Array->new($thing);    }    elsif ( $ref eq 'HASH' ) {        return TAP::Parser::Iterator::Process->new($thing);    }    else {        die "Can't iterate with a $ref";    }}sub next {    my $self = shift;    my $line = $self->next_raw;    # vms nit:  When encountering 'not ok', vms often has the 'not' on a line    # by itself:    #   not    #   ok 1 - 'I hate VMS'    if ( defined($line) and $line =~ /^\s*not\s*$/ ) {        $line .= ( $self->next_raw || '' );    }    return $line;}=head3 C<handle_unicode>If necessary switch the input stream to handle unicode. This only hasany effect for I/O handle based streams.=cutsub handle_unicode { }=head3 C<get_select_handles>Return a list of filehandles that may be used upstream in a select()call to signal that this Iterator is ready. Iterators that are nothandle based should return an empty list.=cutsub get_select_handles {return}1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -