use Class::HPLOO ; class Foo extends Bar , Baz { vars ($VERSION , $GLOBAL_PUBLIC) ; $VERSION = '0.01' ; my $GLOBAL_PRIVATE ; sub Foo (%args) { $this->{X} = $args{x} ; $this->{Y} = $args{y} ; } sub x { $this->{X} } sub y { $this->{Y} } sub test_args ($x , $y , \%opts , \@list , $more ) { print ">> $x\n" ; print ">> $y\n" ; my @keys = map { $_ => 1 } (keys %opts , @list) ; print ">> $more\n" ; } sub old_style { my ( $x , $y ) = @_ ; print ">> $x , $y\n" ; } sub test_html_block { print <% html_foo>( $this->x , $this->y ) ; } <% html_foo($x , $y)
X: $x , Y: $y
%> } #### { package Foo ; use vars qw(@ISA) ; push(@ISA , qw(Bar Baz UNIVERSAL)) ; sub new { my $class = shift ; my $this = bless({} , $class) ; my $ret_this = $this->Foo(@_) if defined &Foo ; $this = $ret_this if ( UNIVERSAL::isa($ret_this,$class) ) ; $this = undef if ( $ret_this eq '0' ) ; return $this ; } sub CLASS_HPLOO_HTML { return '' if !$CLASS_HPLOO_HTML{$_[0]} ; no strict ; return eval( ${$CLASS_HPLOO_HTML{$_[0]}}[0] . " <{X} = $args{x} ; $this->{Y} = $args{y} ; } sub x { my $this = shift ; $this->{X} } sub y { my $this = shift ; $this->{Y} } sub test_args { my $this = shift ; my $x = shift(@_) ; my $y = shift(@_) ; my %opts = ref($_[0]) eq 'HASH' ? %{ shift(@_) } : ( ref($_[0]) eq 'ARRAY' ? @{ shift(@_) } : shift(@_) ) ; my @list = ref($_[0]) eq 'ARRAY' ? @{ shift(@_) } : ( ref($_[0]) eq 'HASH' ? %{ shift(@_) } : shift(@_) ) ; my $more = shift(@_) ; print ">> $x\n" ; print ">> $y\n" ; my @keys = map { $_ => 1 } (keys %opts , @list) ; print ">> $more\n" ; } sub old_style { my $this = shift ; my ( $x , $y ) = @_ ; print ">> $x , $y\n" ; } sub test_html_block { my $this = shift ; print CLASS_HPLOO_HTML('_foo',( $this->x , $this->y )) ; } $CLASS_HPLOO_HTML{'_foo'} = [ q`my $x = shift(@_) ;my $y = shift(@_) ;` , <<'CLASS_HPLOO_HTML' ];
X: $x , Y: $y
CLASS_HPLOO_HTML } 1;