| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #importloop.pm | 
| 2 |  |  |  |  |  |  | #Last Change: 2009-02-04 | 
| 3 |  |  |  |  |  |  | #Copyright (c) 2009 Marc-Seabstian "Maluku" Lucksch | 
| 4 |  |  |  |  |  |  | #Version 0.2 | 
| 5 |  |  |  |  |  |  | #################### | 
| 6 |  |  |  |  |  |  | #This file is part of the Dotiac::DTL project. | 
| 7 |  |  |  |  |  |  | #http://search.cpan.org/perldoc?Dotiac::DTL | 
| 8 |  |  |  |  |  |  | # | 
| 9 |  |  |  |  |  |  | #import.pm is published under the terms of the MIT license, which basically | 
| 10 |  |  |  |  |  |  | #means "Do with it whatever you want". For more inimportmation, see the | 
| 11 |  |  |  |  |  |  | #license.txt file that should be enclosed with libsofu distributions. A copy of | 
| 12 |  |  |  |  |  |  | #the license is (at the time of writing) also available at | 
| 13 |  |  |  |  |  |  | #http://www.opensource.org/licenses/mit-license.php . | 
| 14 |  |  |  |  |  |  | ############################################################################### | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | package Dotiac::DTL::Tag::importloop; | 
| 17 | 1 |  |  | 1 |  | 6 | use base qw/Dotiac::DTL::Tag/; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 76 |  | 
| 18 | 1 |  |  | 1 |  | 5 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 27 |  | 
| 19 | 1 |  |  | 1 |  | 5 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 2397 |  | 
| 20 |  |  |  |  |  |  | require Scalar::Util; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | our $VERSION = 0.2; | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | sub new { | 
| 25 | 8 |  |  | 8 | 1 | 15932 | my $class=shift; | 
| 26 | 8 |  |  |  |  | 20 | my $self={p=>shift()}; | 
| 27 | 8 |  |  |  |  | 14 | my $name=shift; | 
| 28 | 8 |  |  |  |  | 27 | my %name = Dotiac::DTL::get_variables($name,"reversed","merge","contextvars"); | 
| 29 | 8 |  |  |  |  | 516 | $self->{source}=shift @{$name{""}}; | 
|  | 8 |  |  |  |  | 20 |  | 
| 30 | 8 | 100 |  |  |  | 26 | if ($name{reversed}) { | 
| 31 | 3 |  |  |  |  | 7 | $self->{rev}=1; | 
| 32 |  |  |  |  |  |  | } | 
| 33 | 8 | 100 |  |  |  | 23 | if ($name{merge}) { | 
| 34 | 3 |  |  |  |  | 4 | $self->{merge}=1; | 
| 35 |  |  |  |  |  |  | } | 
| 36 | 8 | 100 |  |  |  | 21 | if ($name{contextvars}) { | 
| 37 | 2 |  |  |  |  | 4 | $self->{contextvars}=1; | 
| 38 |  |  |  |  |  |  | } | 
| 39 | 8 |  |  |  |  | 17 | foreach my $e (map {@{$name{$_}}} keys %name) { | 
|  | 16 |  |  |  |  | 16 |  | 
|  | 16 |  |  |  |  | 34 |  | 
| 40 | 0 | 0 |  |  |  | 0 | if ($e eq "contextvars") { | 
|  |  | 0 |  |  |  |  |  | 
|  |  | 0 |  |  |  |  |  | 
| 41 | 0 |  |  |  |  | 0 | $self->{contextvars}=1; | 
| 42 |  |  |  |  |  |  | } | 
| 43 |  |  |  |  |  |  | elsif ($e eq "merge") { | 
| 44 | 0 |  |  |  |  | 0 | $self->{merge}=1; | 
| 45 |  |  |  |  |  |  | } | 
| 46 |  |  |  |  |  |  | elsif ($e eq "reversed") { | 
| 47 | 0 |  |  |  |  | 0 | $self->{rev}=1; | 
| 48 |  |  |  |  |  |  | } | 
| 49 |  |  |  |  |  |  | } | 
| 50 | 8 | 50 |  |  |  | 20 | die "Can't use \"importloop\" without a datasource" unless $self->{source}; | 
| 51 | 8 |  |  |  |  | 10 | my $obj=shift; | 
| 52 | 8 |  |  |  |  | 11 | my $data=shift; | 
| 53 | 8 |  |  |  |  | 10 | my $pos=shift; | 
| 54 | 8 |  |  |  |  | 9 | my $found=""; | 
| 55 | 8 |  |  |  |  | 30 | $self->{content}=$obj->parse($data,$pos,\$found,"endimportloop","empty"); | 
| 56 | 8 | 100 |  |  |  | 2040 | if ($found eq "empty") { | 
| 57 | 5 |  |  |  |  | 17 | $self->{empty}=$obj->parse($data,$pos,\$found,"endimportloop"); | 
| 58 |  |  |  |  |  |  | } | 
| 59 | 8 |  |  |  |  | 236 | bless $self,$class; | 
| 60 | 8 |  |  |  |  | 30 | return $self; | 
| 61 |  |  |  |  |  |  | } | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | sub perl { | 
| 64 | 8 |  |  | 8 | 1 | 1208 | my $self=shift; | 
| 65 | 8 |  |  |  |  | 13 | my $fh=shift; | 
| 66 | 8 |  |  |  |  | 10 | my $id=shift; | 
| 67 | 8 |  |  |  |  | 28 | $self->SUPER::perl($fh,$id,@_); | 
| 68 | 8 |  |  |  |  | 368 | print $fh "my "; | 
| 69 | 8 |  |  |  |  | 41 | print $fh (Data::Dumper->Dump([$self->{source}],["\$source$id"])); | 
| 70 | 8 |  |  |  |  | 295 | $id=$self->{content}->perl($fh,$id+1,@_); | 
| 71 | 8 | 100 |  |  |  | 3219 | $id=$self->{empty}->perl($fh,$id+1,@_) if $self->{empty}; | 
| 72 | 8 |  |  |  |  | 292 | return $self->{n}->perl($fh,$id+1,@_); | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  |  | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  |  | 
| 78 |  |  |  |  |  |  | sub print { | 
| 79 | 8 |  |  | 8 | 1 | 2981 | my $self=shift; | 
| 80 | 8 |  |  |  |  | 50 | print $self->{p}; | 
| 81 | 8 |  |  |  |  | 26 | my $var=Dotiac::DTL::devar_raw($self->{source},@_); | 
| 82 | 8 |  |  |  |  | 302 | my $vars=shift; | 
| 83 | 8 |  |  |  |  | 15 | my $merge=$self->{merge}; | 
| 84 | 8 |  |  |  |  | 11 | my $cv=$self->{contextvars}; | 
| 85 | 8 |  |  |  |  | 13 | my @loop=(); | 
| 86 | 18 |  |  |  |  | 150 | @loop=grep { | 
| 87 | 6 |  |  |  |  | 40 | Scalar::Util::reftype($_) eq "HASH"; | 
| 88 | 8 | 100 |  |  |  | 20 | } @{$var->content} if $var->array; | 
| 89 | 8 | 100 |  |  |  | 29 | if (@loop) { | 
| 90 | 6 | 100 |  |  |  | 17 | @loop=reverse @loop if $self->{rev}; | 
| 91 | 6 |  |  |  |  | 16 | foreach my $v (0 .. $#loop) { | 
| 92 | 18 |  |  |  |  | 3231 | my $newvars; | 
| 93 | 18 | 100 |  |  |  | 30 | if ($merge) { | 
| 94 | 6 | 50 |  |  |  | 19 | $newvars={%{$vars},%{$loop[$v]}} if $merge; | 
|  | 6 |  |  |  |  | 14 |  | 
|  | 6 |  |  |  |  | 25 |  | 
| 95 |  |  |  |  |  |  | } | 
| 96 |  |  |  |  |  |  | else { | 
| 97 | 12 |  |  |  |  | 11 | $newvars={%{$loop[$v]}}; | 
|  | 12 |  |  |  |  | 41 |  | 
| 98 |  |  |  |  |  |  | } | 
| 99 | 18 | 100 |  |  |  | 43 | if ($cv) { #HTML::Template like loop_context_vars: | 
| 100 | 6 |  |  |  |  | 11 | $newvars->{__first__}=($v == 0); | 
| 101 | 6 |  | 100 |  |  | 26 | $newvars->{__inner__}=($v!=0 and $v!=$#loop); | 
| 102 | 6 |  |  |  |  | 11 | $newvars->{__last__}=($v == $#loop); | 
| 103 | 6 |  |  |  |  | 10 | $newvars->{__counter__}=$v+1; | 
| 104 | 6 |  |  |  |  | 56 | $newvars->{__odd__}=!($v%2); | 
| 105 |  |  |  |  |  |  | } | 
| 106 | 18 |  |  |  |  | 61 | $self->{content}->print($newvars,@_); | 
| 107 |  |  |  |  |  |  |  | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | } | 
| 110 |  |  |  |  |  |  | } | 
| 111 |  |  |  |  |  |  | else { | 
| 112 | 2 | 50 |  |  |  | 10 | $self->{empty}->print($vars,@_) if $self->{empty}; | 
| 113 |  |  |  |  |  |  | } | 
| 114 | 8 |  |  |  |  | 1508 | $self->{n}->print($vars,@_); | 
| 115 |  |  |  |  |  |  | } | 
| 116 |  |  |  |  |  |  | sub string { | 
| 117 | 8 |  |  | 8 | 1 | 2176 | my $self=shift; | 
| 118 | 8 |  |  |  |  | 31 | my $var=Dotiac::DTL::devar_raw($self->{source},@_); | 
| 119 | 8 |  |  |  |  | 368 | my $vars=shift; | 
| 120 | 8 |  |  |  |  | 15 | my $merge=$self->{merge}; | 
| 121 | 8 |  |  |  |  | 12 | my $cv=$self->{contextvars}; | 
| 122 | 8 |  |  |  |  | 14 | my @loop=(); | 
| 123 | 8 |  |  |  |  | 12 | my $r=""; | 
| 124 | 18 |  |  |  |  | 71 | @loop=grep { | 
| 125 | 6 |  |  |  |  | 49 | Scalar::Util::reftype($_) eq "HASH"; | 
| 126 | 8 | 100 |  |  |  | 25 | } @{$var->content} if $var->array; | 
| 127 | 8 | 100 |  |  |  | 26 | if (@loop) { | 
| 128 | 6 | 100 |  |  |  | 18 | @loop=reverse @loop if $self->{rev}; | 
| 129 | 6 |  |  |  |  | 18 | foreach my $v (0 .. $#loop) { | 
| 130 | 18 |  |  |  |  | 3125 | my $newvars; | 
| 131 | 18 | 100 |  |  |  | 31 | if ($merge) { #HTML::Template like global_vars | 
| 132 | 6 | 50 |  |  |  | 14 | $newvars={%{$vars},%{$loop[$v]}} if $merge; | 
|  | 6 |  |  |  |  | 13 |  | 
|  | 6 |  |  |  |  | 26 |  | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  | else { | 
| 135 | 12 |  |  |  |  | 13 | $newvars={%{$loop[$v]}}; | 
|  | 12 |  |  |  |  | 62 |  | 
| 136 |  |  |  |  |  |  | } | 
| 137 | 18 | 100 |  |  |  | 45 | if ($cv) { #HTML::Template like loop_context_vars: | 
| 138 | 6 |  |  |  |  | 11 | $newvars->{__first__}=($v == 0); | 
| 139 | 6 |  | 100 |  |  | 27 | $newvars->{__inner__}=($v!=0 and $v!=$#loop); | 
| 140 | 6 |  |  |  |  | 9 | $newvars->{__last__}=($v == $#loop); | 
| 141 | 6 |  |  |  |  | 13 | $newvars->{__counter__}=$v+1; | 
| 142 | 6 |  |  |  |  | 14 | $newvars->{__odd__}=!($v%2); | 
| 143 |  |  |  |  |  |  | } | 
| 144 | 18 |  |  |  |  | 61 | $r.=$self->{content}->string($newvars,@_); | 
| 145 |  |  |  |  |  |  | } | 
| 146 |  |  |  |  |  |  | } | 
| 147 |  |  |  |  |  |  | else { | 
| 148 | 2 | 50 |  |  |  | 13 | $r.=$self->{empty}->string($vars,@_) if $self->{empty}; | 
| 149 |  |  |  |  |  |  | } | 
| 150 | 8 |  |  |  |  | 1573 | return $self->{p}.$r.$self->{n}->string($vars,@_); | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | } | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | sub perlprint { | 
| 155 | 8 |  |  | 8 | 1 | 832 | my $self=shift; | 
| 156 | 8 |  |  |  |  | 9 | my $fh=shift; | 
| 157 | 8 |  |  |  |  | 8 | my $id=shift; | 
| 158 | 8 |  |  |  |  | 9 | my $level=shift; | 
| 159 | 8 |  |  |  |  | 30 | $self->SUPER::perlprint($fh,$id,$level,@_); | 
| 160 | 8 |  |  |  |  | 407 | my $in="\t" x $level; | 
| 161 | 8 |  |  |  |  | 22 | print $fh $in,"my \$importvar$id = Dotiac::DTL::devar_raw(\$source$id,\$vars,\$escape,\@_);\n"; | 
| 162 | 8 | 100 |  |  |  | 426 | print $fh $in,"my \$importvars$id = \$vars;\n" if $self->{merge}; | 
| 163 | 8 |  |  |  |  | 16 | print $fh $in,"my \@importloop$id = ();\n"; | 
| 164 | 8 |  |  |  |  | 17 | print $fh $in,"my \$ref$id = Scalar::Util::reftype(\$importvar$id);\n"; | 
| 165 | 8 |  |  |  |  | 201 | print $fh $in,"\@importloop$id=grep { Scalar::Util::reftype(\$_) eq \"HASH\"} \@{\$importvar$id->content} if \$importvar$id->array;\n"; | 
| 166 | 8 | 100 |  |  |  | 26 | print $fh $in,"\@importloop$id = reverse \@importloop$id;\n" if $self->{rev}; | 
| 167 | 8 | 100 |  |  |  | 20 | if ($self->{empty}) { | 
| 168 | 5 |  |  |  |  | 11 | print $fh $in,"if (\@importloop$id) {\n"; | 
| 169 | 5 |  |  |  |  | 12 | print $fh $in,"\tforeach my \$loop (0 .. \$#importloop$id) {\n"; | 
| 170 | 5 |  |  |  |  | 6 | $level++; | 
| 171 |  |  |  |  |  |  | } | 
| 172 |  |  |  |  |  |  | else { | 
| 173 | 3 |  |  |  |  | 10 | print $fh $in,"foreach my \$loop (0 .. \$#importloop$id) {\n"; | 
| 174 |  |  |  |  |  |  | } | 
| 175 | 8 |  |  |  |  | 21 | my $in2="\t" x ($level+1); | 
| 176 | 8 | 100 |  |  |  | 207 | if ($self->{merge}) { | 
| 177 | 3 |  |  |  |  | 13 | print $fh $in2, "my \$vars={\%{\$importvars$id},\%{\$importloop$id"."[\$loop]}};"; | 
| 178 |  |  |  |  |  |  | } | 
| 179 |  |  |  |  |  |  | else { | 
| 180 | 5 |  |  |  |  | 12 | print $fh $in2, "my \$vars={\%{\$importloop$id"."[\$loop]}};"; | 
| 181 |  |  |  |  |  |  | } | 
| 182 | 8 | 100 |  |  |  | 200 | if ($self->{contextvars}) { #HTML::Template like loop_context_vars: | 
| 183 | 2 |  |  |  |  | 3 | print $fh $in2, "\$vars->{__first__}=(\$loop == 0);\n"; | 
| 184 | 2 |  |  |  |  | 5 | print $fh $in2, "\$vars->{__inner__}=(\$loop!=0 and \$loop!=\$#importloop$id);\n"; | 
| 185 | 2 |  |  |  |  | 5 | print $fh $in2, "\$vars->{__last__}=(\$loop == \$#importloop$id);\n"; | 
| 186 | 2 |  |  |  |  | 3 | print $fh $in2, "\$vars->{__counter__}=\$loop+1;\n"; | 
| 187 | 2 |  |  |  |  | 4 | print $fh $in2, "\$vars->{__odd__}=!(\$loop%2);\n"; | 
| 188 |  |  |  |  |  |  | } | 
| 189 | 8 |  |  |  |  | 35 | $id = $self->{content}->perlprint($fh,$id+1,$level+1,@_); | 
| 190 | 8 | 100 |  |  |  | 1183 | if ($self->{empty}) { | 
| 191 | 5 |  |  |  |  | 8 | print $fh $in,"\t}\n"; | 
| 192 | 5 |  |  |  |  | 5 | print $fh $in,"} else {\n"; | 
| 193 | 5 |  |  |  |  | 20 | $id = $self->{empty}->perlprint($fh,$id+1,$level+1,@_); | 
| 194 | 5 |  |  |  |  | 55 | print $fh $in,"}\n"; | 
| 195 | 5 |  |  |  |  | 6 | $level--; | 
| 196 |  |  |  |  |  |  | } | 
| 197 |  |  |  |  |  |  | else { | 
| 198 | 3 |  |  |  |  | 10 | print $fh $in,"}\n"; | 
| 199 |  |  |  |  |  |  | } | 
| 200 | 8 |  |  |  |  | 44 | return $self->{n}->perlprint($fh,$id+1,$level,@_); | 
| 201 |  |  |  |  |  |  | } | 
| 202 |  |  |  |  |  |  | sub perlstring { | 
| 203 | 8 |  |  | 8 | 1 | 111 | my $self=shift; | 
| 204 | 8 |  |  |  |  | 10 | my $fh=shift; | 
| 205 | 8 |  |  |  |  | 10 | my $id=shift; | 
| 206 | 8 |  |  |  |  | 8 | my $level=shift; | 
| 207 | 8 |  |  |  |  | 26 | $self->SUPER::perlstring($fh,$id,$level,@_); | 
| 208 | 8 |  |  |  |  | 54 | my $in="\t" x $level; | 
| 209 | 8 |  |  |  |  | 24 | print $fh $in,"my \$importvar$id = Dotiac::DTL::devar_raw(\$source$id,\$vars,\$escape,\@_);\n"; | 
| 210 | 8 | 100 |  |  |  | 26 | print $fh $in,"my \$importvars$id = \$vars;\n" if $self->{merge}; | 
| 211 | 8 |  |  |  |  | 26 | print $fh $in,"my \@importloop$id = ();\n"; | 
| 212 | 8 |  |  |  |  | 38 | print $fh $in,"my \$ref$id = Scalar::Util::reftype(\$importvar$id);\n"; | 
| 213 | 8 |  |  |  |  | 25 | print $fh $in,"\@importloop$id=grep { Scalar::Util::reftype(\$_) eq \"HASH\"} \@{\$importvar$id->content} if \$importvar$id"."->array;\n"; | 
| 214 | 8 | 100 |  |  |  | 25 | print $fh $in,"\@importloop$id = reverse \@importloop$id;\n" if $self->{rev}; | 
| 215 | 8 | 100 |  |  |  | 18 | if ($self->{empty}) { | 
| 216 | 5 |  |  |  |  | 12 | print $fh $in,"if (\@importloop$id) {\n"; | 
| 217 | 5 |  |  |  |  | 9 | print $fh $in,"\tforeach my \$loop (0 .. \$#importloop$id) {\n"; | 
| 218 | 5 |  |  |  |  | 7 | $level++; | 
| 219 |  |  |  |  |  |  | } | 
| 220 |  |  |  |  |  |  | else { | 
| 221 | 3 |  |  |  |  | 8 | print $fh $in,"foreach my \$loop (0 .. \$#importloop$id) {\n"; | 
| 222 |  |  |  |  |  |  | } | 
| 223 | 8 |  |  |  |  | 19 | my $in2="\t" x ($level+1); | 
| 224 | 8 | 100 |  |  |  | 17 | if ($self->{merge}) { | 
| 225 | 3 |  |  |  |  | 9 | print $fh $in2, "my \$vars={\%{\$importvars$id},\%{\$importloop$id"."[\$loop]}};"; | 
| 226 |  |  |  |  |  |  | } | 
| 227 |  |  |  |  |  |  | else { | 
| 228 | 5 |  |  |  |  | 14 | print $fh $in2, "my \$vars={\%{\$importloop$id"."[\$loop]}};"; | 
| 229 |  |  |  |  |  |  | } | 
| 230 | 8 | 100 |  |  |  | 22 | if ($self->{contextvars}) { #HTML::Template like loop_context_vars: | 
| 231 | 2 |  |  |  |  | 4 | print $fh $in2, "\$vars->{__first__}=(\$loop == 0);\n"; | 
| 232 | 2 |  |  |  |  | 6 | print $fh $in2, "\$vars->{__inner__}=(\$loop!=0 and \$loop!=\$#importloop$id);\n"; | 
| 233 | 2 |  |  |  |  | 7 | print $fh $in2, "\$vars->{__last__}=(\$loop == \$#importloop$id);\n"; | 
| 234 | 2 |  |  |  |  | 3 | print $fh $in2, "\$vars->{__counter__}=\$loop+1;\n"; | 
| 235 | 2 |  |  |  |  | 3 | print $fh $in2, "\$vars->{__odd__}=!(\$loop%2);\n"; | 
| 236 |  |  |  |  |  |  | } | 
| 237 | 8 |  |  |  |  | 38 | $id = $self->{content}->perlstring($fh,$id+1,$level+1,@_); | 
| 238 | 8 | 100 |  |  |  | 723 | if ($self->{empty}) { | 
| 239 | 5 |  |  |  |  | 10 | print $fh $in,"\t}\n"; | 
| 240 | 5 |  |  |  |  | 7 | print $fh $in,"} else {\n"; | 
| 241 | 5 |  |  |  |  | 19 | $id = $self->{empty}->perlstring($fh,$id+1,$level+1,@_); | 
| 242 | 5 |  |  |  |  | 53 | print $fh $in,"}\n"; | 
| 243 | 5 |  |  |  |  | 8 | $level--; | 
| 244 |  |  |  |  |  |  | } | 
| 245 |  |  |  |  |  |  | else { | 
| 246 | 3 |  |  |  |  | 7 | print $fh $in,"}\n"; | 
| 247 |  |  |  |  |  |  | } | 
| 248 | 8 |  |  |  |  | 3529 | return $self->{n}->perlstring($fh,$id+1,$level,@_); | 
| 249 |  |  |  |  |  |  | } | 
| 250 |  |  |  |  |  |  |  | 
| 251 |  |  |  |  |  |  | sub perleval { | 
| 252 | 8 |  |  | 8 | 1 | 86 | my $self=shift; | 
| 253 | 8 |  |  |  |  | 8 | my $fh=shift; | 
| 254 | 8 |  |  |  |  | 9 | my $id=shift; | 
| 255 | 8 |  |  |  |  | 34 | $id=$self->{content}->perleval($fh,$id+1,@_); | 
| 256 | 8 | 100 |  |  |  | 204 | $id=$self->{empty}->perleval($fh,$id+1,@_) if $self->{empty}; | 
| 257 | 8 |  |  |  |  | 41 | $self->{n}->perleval($fh,$id+1,@_); | 
| 258 |  |  |  |  |  |  | } | 
| 259 |  |  |  |  |  |  | sub perlcount { | 
| 260 | 0 |  |  | 0 | 1 | 0 | my $self=shift; | 
| 261 | 0 |  |  |  |  | 0 | my $id=shift; | 
| 262 | 0 |  |  |  |  | 0 | $id=$self->{content}->perlcount($id+1,@_); | 
| 263 | 0 | 0 |  |  |  | 0 | $id=$self->{empty}->perlcount($id+1,@_) if $self->{empty}; | 
| 264 | 0 |  |  |  |  | 0 | return $self->{n}->perlcount($id+1); | 
| 265 |  |  |  |  |  |  | } | 
| 266 |  |  |  |  |  |  | sub perlinit { | 
| 267 | 8 |  |  | 8 | 1 | 163 | my $self=shift; | 
| 268 | 8 |  |  |  |  | 12 | my $fh=shift; | 
| 269 | 8 |  |  |  |  | 10 | my $id=shift; | 
| 270 | 8 |  |  |  |  | 26 | $id=$self->{content}->perlinit($fh,$id+1,@_); | 
| 271 | 8 | 100 |  |  |  | 170 | $id=$self->{empty}->perlinit($fh,$id+1,@_) if $self->{empty}; | 
| 272 | 8 |  |  |  |  | 40 | return $self->{n}->perlinit($fh,$id+1); | 
| 273 |  |  |  |  |  |  | } | 
| 274 |  |  |  |  |  |  | sub next { | 
| 275 | 8 |  |  | 8 | 1 | 93 | my $self=shift; | 
| 276 | 8 |  |  |  |  | 25 | $self->{n}=shift; | 
| 277 |  |  |  |  |  |  | } | 
| 278 |  |  |  |  |  |  | sub eval { | 
| 279 | 0 |  |  | 0 | 1 |  | my $self=shift; | 
| 280 | 0 |  |  |  |  |  | $self->{n}->eval(@_); | 
| 281 |  |  |  |  |  |  | } | 
| 282 |  |  |  |  |  |  | 1; | 
| 283 |  |  |  |  |  |  |  | 
| 284 |  |  |  |  |  |  | __END__ |