-
-
Save anonymous/fe763c0a65ac45b8eb8a to your computer and use it in GitHub Desktop.
hardoded builder
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/env perl | |
use strict; | |
use warnings; | |
use Moose::Util::TypeConstraints; | |
use MooseX::Types::Moose qw/ ArrayRef Str/; | |
coerce Str, | |
from ArrayRef, | |
via { | |
my $data = $_; | |
my @attribs = split "/","foo/bar/baz"; | |
my $i = 0; | |
return join ("",map { | |
"<$_>$data->[$i++]"; | |
} @attribs) . join ("",map { "</$_>" } reverse @attribs); | |
}; | |
{ | |
package Foo; | |
use Moose; | |
has "elem" => ( is => "rw", isa => "Str", coerce => 1, ); | |
1; | |
} | |
## main | |
my $f = Foo->new(elem => ["Ted", "Tampa, FL", 100]); | |
print $f->elem(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment