package HTML::Element; use strict; use warnings; use Exporter 'import'; our @EXPORT = qw( html head title body h1 p br table Tr td ); our $AUTOLOAD; sub new { bless {}, shift } sub AUTOLOAD { my $self = ref($_[0]) eq __PACKAGE__ ? shift : undef; my $attr = ref($_[0]) eq 'HASH' ? shift : {}; my $tag = $AUTOLOAD =~ s/.*:://r; my $attr_txt = ''; $attr_txt .= qq( $_="$attr->{$_}") for keys %$attr; return @_ ? "<$tag$attr_txt>@_" : "<$tag$attr_txt />"; } 1;