package PrintHtml; # Print class to print a string in html format use warnings; use strict; use Carp; use Print; sub new { my $type = shift; my $class = ref $type || $type; # itsPrint is private! my $itsPrint = shift; my $self = { itsPrint => $itsPrint, }; my $closure = sub { my $field = shift; return $self->{$field}; }; bless ($closure,$class); return $closure; } sub print { my $self = shift; print "

\n"; &{ $_[0]}("itsPrint")->print; print "

\n"; } 1;