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

📄 pod3html

📁 PDF-API2-0.2.3.7_dev.tar.gz
💻
📖 第 1 页 / 共 5 页
字号:
a scalar context, it returns a string containing the filename, followedby a colon (':'), followed by the line number.=cutsub file_line {   my @loc = ($_[0]->{'-file'} || '<unknown-file>',              $_[0]->{'-line'} || 0);   return (wantarray) ? @loc : join(':', @loc);}##---------------------------------------------------------------------------#############################################################################package Pod::InteriorSequence;##---------------------------------------------------------------------------=head1 B<Pod::InteriorSequence>An object representing a POD interior sequence command.It has the following methods/attributes:=cut##---------------------------------------------------------------------------=head2 Pod::InteriorSequence-E<gt>B<new()>        my $pod_seq1 = Pod::InteriorSequence->new(-name => $cmd                                                  -ldelim => $delimiter);        my $pod_seq2 = new Pod::InteriorSequence(-name => $cmd,                                                 -ldelim => $delimiter);        my $pod_seq3 = new Pod::InteriorSequence(-name => $cmd,                                                 -ldelim => $delimiter,                                                 -file => $filename,                                                 -line => $line_number);        my $pod_seq4 = new Pod::InteriorSequence(-name => $cmd, $ptree);        my $pod_seq5 = new Pod::InteriorSequence($cmd, $ptree);This is a class method that constructs a C<Pod::InteriorSequence> objectand returns a reference to the new interior sequence object. It shouldbe given two keyword arguments.  The C<-ldelim> keyword indicates thecorresponding left-delimiter of the interior sequence (e.g. 'E<lt>').The C<-name> keyword indicates the name of the corresponding interiorsequence command, such as C<I> or C<B> or C<C>. The C<-file> andC<-line> keywords indicate the filename and line number correspondingto the beginning of the interior sequence. If the C<$ptree> argument isgiven, it must be the last argument, and it must be either string, orelse an array-ref suitable for passing to B<Pod::ParseTree::new> (orit may be a reference to an Pod::ParseTree object).=cutsub new {    ## Determine if we were called via an object-ref or a classname    my $this = shift;    my $class = ref($this) || $this;    ## See if first argument has no keyword    if (((@_ <= 2) or (@_ % 2)) and $_[0] !~ /^-\w/) {       ## Yup - need an implicit '-name' before first parameter       unshift @_, '-name';    }    ## See if odd number of args    if ((@_ % 2) != 0) {       ## Yup - need an implicit '-ptree' before the last parameter       splice @_, $#_, 0, '-ptree';    }    ## Any remaining arguments are treated as initial values for the    ## hash that is used to represent this object. Note that we default    ## certain values by specifying them *before* the arguments passed.    ## If they are in the argument list, they will override the defaults.    my $self = {          -name       => (@_ == 1) ? $_[0] : undef,          -file       => '<unknown-file>',          -line       => 0,          -ldelim     => '<',          -rdelim     => '>',          @_    };    ## Initialize contents if they havent been already    my $ptree = $self->{'-ptree'} || new Pod::ParseTree();    if ( ref $ptree =~ /^(ARRAY)?$/ ) {        ## We have an array-ref, or a normal scalar. Pass it as an        ## an argument to the ptree-constructor        $ptree = new Pod::ParseTree($1 ? [$ptree] : $ptree);    }    $self->{'-ptree'} = $ptree;    ## Bless ourselves into the desired class and perform any initialization    bless $self, $class;    return $self;}##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<cmd_name()>        my $seq_cmd = $pod_seq->cmd_name();The name of the interior sequence command.=cutsub cmd_name {   (@_ > 1)  and  $_[0]->{'-name'} = $_[1];   return $_[0]->{'-name'};}## let name() be an alias for cmd_name()*name = \&cmd_name;##---------------------------------------------------------------------------## Private subroutine to set the parent pointer of all the given## children that are interior-sequences to be $selfsub _set_child2parent_links {   my ($self, @children) = @_;   ## Make sure any sequences know who their parent is   for (@children) {      next  unless (length  and  ref  and  ref ne 'SCALAR');      if (UNIVERSAL::isa($_, 'Pod::InteriorSequence') or          UNIVERSAL::can($_, 'nested'))      {          $_->nested($self);      }   }}## Private subroutine to unset child->parent linkssub _unset_child2parent_links {   my $self = shift;   $self->{'-parent_sequence'} = undef;   my $ptree = $self->{'-ptree'};   for (@$ptree) {      next  unless (length  and  ref  and  ref ne 'SCALAR');      $_->_unset_child2parent_links()          if UNIVERSAL::isa($_, 'Pod::InteriorSequence');   }}##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<prepend()>        $pod_seq->prepend($text);        $pod_seq1->prepend($pod_seq2);Prepends the given string or parse-tree or sequence object to the parse-treeof this interior sequence.=cutsub prepend {   my $self  = shift;   $self->{'-ptree'}->prepend(@_);   _set_child2parent_links($self, @_);   return $self;}       ##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<append()>        $pod_seq->append($text);        $pod_seq1->append($pod_seq2);Appends the given string or parse-tree or sequence object to the parse-treeof this interior sequence.=cutsub append {   my $self = shift;   $self->{'-ptree'}->append(@_);   _set_child2parent_links($self, @_);   return $self;}       ##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<nested()>        $outer_seq = $pod_seq->nested || print "not nested";If this interior sequence is nested inside of another interiorsequence, then the outer/parent sequence that contains it isreturned. Otherwise C<undef> is returned.=cutsub nested {   my $self = shift;  (@_ == 1)  and  $self->{'-parent_sequence'} = shift;   return  $self->{'-parent_sequence'} || undef;}##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<raw_text()>        my $seq_raw_text = $pod_seq->raw_text();This method will return the I<raw> text of the POD interior sequence,exactly as it appeared in the input.=cutsub raw_text {   my $self = shift;   my $text = $self->{'-name'} . $self->{'-ldelim'};   for ( $self->{'-ptree'}->children ) {      $text .= (ref $_) ? $_->raw_text : $_;   }   $text .= $self->{'-rdelim'};   return $text;}##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<left_delimiter()>        my $ldelim = $pod_seq->left_delimiter();The leftmost delimiter beginning the argument text to the interiorsequence (should be "<").=cutsub left_delimiter {   (@_ > 1)  and  $_[0]->{'-ldelim'} = $_[1];   return $_[0]->{'-ldelim'};}## let ldelim() be an alias for left_delimiter()*ldelim = \&left_delimiter;##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<right_delimiter()>The rightmost delimiter beginning the argument text to the interiorsequence (should be ">").=cutsub right_delimiter {   (@_ > 1)  and  $_[0]->{'-rdelim'} = $_[1];   return $_[0]->{'-rdelim'};}## let rdelim() be an alias for right_delimiter()*rdelim = \&right_delimiter;##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<parse_tree()>        my $ptree = $pod_parser->parse_text($paragraph_text);        $pod_seq->parse_tree( $ptree );        $ptree = $pod_seq->parse_tree();This method will get/set the corresponding parse-tree of the interiorsequence's text.=cutsub parse_tree {   (@_ > 1)  and  $_[0]->{'-ptree'} = $_[1];   return $_[0]->{'-ptree'};}       ## let ptree() be an alias for parse_tree()*ptree = \&parse_tree;##---------------------------------------------------------------------------=head2 $pod_seq-E<gt>B<file_line()>        my ($filename, $line_number) = $pod_seq->file_line();        my $position = $pod_seq->file_line();Returns the current filename and line number for the interior sequenceobject.  If called in a list context, it returns a list of twoelements: first the filename, then the line number. If called ina scalar context, it returns a string containing the filename, followedby a colon (':'), followed by the line number.=cutsub file_line {   my @loc = ($_[0]->{'-file'}  || '<unknown-file>',              $_[0]->{'-line'}  || 0);   return (wantarray) ? @loc : join(':', @loc);}##---------------------------------------------------------------------------=head2 Pod::InteriorSequence::B<DESTROY()>This method performs any necessary cleanup for the interior-sequence.If you override this method then it is B<imperative> that you invokethe parent method from within your own method, otherwiseI<interior-sequence storage will not be reclaimed upon destruction!>=cutsub DESTROY {   ## We need to get rid of all child->parent pointers throughout the   ## tree so their reference counts will go to zero and they can be   ## garbage-collected   _unset_child2parent_links(@_);}##---------------------------------------------------------------------------#############################################################################package Pod::ParseTree;##---------------------------------------------------------------------------=head1 B<Pod::ParseTree>This object corresponds to a tree of parsed POD text. As POD text isscanned from left to right, it is parsed into an ordered list oftext-strings and B<Pod::InteriorSequence> objects (in order ofappearance). A B<Pod::ParseTree> object corresponds to this list ofstrings and sequences. Each interior sequence in the parse-tree mayitself contain a parse-tree (since interior sequences may be nested).=cut##---------------------------------------------------------------------------=head2 Pod::ParseTree-E<gt>B<new()>        my $ptree1 = Pod::ParseTree->new;        my $ptree2 = new Pod::ParseTree;        my $ptree4 = Pod::ParseTree->new($array_ref);        my $ptree3 = new Pod::ParseTree($array_ref);This is a class method that constructs a C<Pod::Parse_tree> object andreturns a reference to the new parse-tree. If a single-argument is given,it must be a reference to an array, and is used to initialize the root(top) of the parse tree.=cutsub new {    ## Determine if we were called via an object-ref or a classname    my $this = shift;    my $class = ref($this) || $this;    my $self = (@_ == 1  and  ref $_[0]) ? $_[0] : [];    ## Bless ourselves into the desired class and perform any initialization    bless $self, $class;    return $self;}##---------------------------------------------------------------------------=head2 $ptree-E<gt>B<top()>        my $top_node = $ptree->top();        $ptree->top( $top_node );        $ptree->top( @children );This method gets/sets the top node of the parse-tree. If no arguments aregiven, it returns the topmost node in the tree (the root), which is alsoa B<Pod::ParseTree>. If it is given a single argument that is a reference,then the reference is assumed to a parse-tree and becomes the new top node.Otherwise, if arguments are given, they are treated as the new list ofchildren for the top node.=cutsub top {   my $self = shift;   if (@_ > 0) {      @{ $self } = (@_ == 1  and  ref $_[0]) ? ${ @_ } : @_;   }   return $self;}## let parse_tree() & ptree() be aliases for the 'top' method*parse_tree = *ptree = \&top;##---------------------------------------------------------------------------

⌨️ 快捷键说明

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