Created
August 24, 2010 11:22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use Data::Dumper::Perltidy; | |
use Getopt::Long; | |
use Perl6::Say; | |
use Pod::Usage; | |
use autodie; | |
use strict; | |
use warnings; | |
our $AUTOLOAD; | |
sub man {#{{{ | |
pod2usage( | |
-exitval => 1, | |
-verbose => 2 | |
); | |
}#}}} | |
# main | |
GetOptions ( | |
'man' => \&man, | |
); | |
sub AUTOLOAD { | |
$AUTOLOAD=~ /.*::(.*)$/; | |
my $fill=''; | |
my @a = split(/_/,$1); | |
if (1<@a) { | |
$fill=" class='$a[1]'"; | |
} | |
return "<$a[0]$fill>\n@_\n</$a[0]>\n"; | |
} | |
say hola( | |
adeu_thisismyclass("hola"), | |
ital() | |
); | |
__END__#{{{ | |
=head1 NAME | |
AutoBuild | |
=head1 SEE ALSO | |
=head1 SYNOPSIS | |
say hola( | |
adeu_thisismyclass("hola"), | |
ital() | |
) | |
outputs | |
<hola > | |
<adeu class='thisismyclass'> | |
hola | |
</adeu> | |
<ital > | |
</ital> | |
</hola> | |
=head1 DESCRIPTION | |
Tiny DSL to dinamically build html-like text based on AUTOLOAD Perl5 feature | |
=head1 AUTHOR | |
Raimon Grau Cuscó <raimonster@gmail.com> | |
=head1 Credits | |
=cut | |
# vim: set tabstop=4 shiftwidth=4 foldmethod=marker : ###}}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment