Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
22
Task/Nested-templated-data/Perl/nested-templated-data-2.pl
Normal file
22
Task/Nested-templated-data/Perl/nested-templated-data-2.pl
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
use strict; # https://rosettacode.org/wiki/Nested_templated_data
|
||||
use warnings;
|
||||
use Data::Dump 'dd';
|
||||
|
||||
my $t = [
|
||||
[[1, 2],
|
||||
[3, 4, 1],
|
||||
5]];
|
||||
|
||||
my $p = [ map "Payload#$_", 0 .. 6 ];
|
||||
dd { 'template' => $t, 'payload' => $p };
|
||||
|
||||
my $output = filltemplate( $t, $p );
|
||||
dd { 'output' => $output };
|
||||
|
||||
sub filltemplate
|
||||
{
|
||||
my ($t, $p) = @_;
|
||||
return ref $t eq 'ARRAY' ? [ map filltemplate($_, $p), @$t ] : $p->[$t];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue