Bucles sobre Hashes

lhp@nereida:~/Lperl/src/template_toolkit/src$ cat -n ex3.pl
     1  #!/usr/local/bin/perl -w
     2  use strict;
     3  use Template;
     4
     5  my $tt = Template->new({
     6      INCLUDE_PATH => '/home/lhp/Lperl/src/template_toolkit/src/tt'
     7  });
     8
     9  my %perlprogs = map { ( $_ => -s $_)  } glob('*.pl');
    10
    11  my %vars = (
    12    files => \%perlprogs,
    13  );
    14  $tt->process('forexkeyvalue', \%vars);
lhp@nereida:~/Lperl/src/template_toolkit/src$ cat -n tt/forexkeyvalue
     1  [% FOREACH file IN  files -%]
     2  [% file.key %] has size  [% file.value %]
     3  [% END %]
lhp@nereida:~/Lperl/src/template_toolkit/src$ ex3.pl
ex1.pl has size  266
ex2.pl has size  288
ex3.pl has size  282

Casiano Rodríguez León
Licencia de Creative Commons
Principios de Programación Imperativa, Funcional y Orientada a Objetos Una Introducción en Perl/Una Introducción a Perl
por Casiano Rodríguez León is licensed under a Creative Commons Reconocimiento 3.0 Unported License.

Permissions beyond the scope of this license may be available at http://campusvirtual.ull.es/ocw/course/view.php?id=43.
2012-06-19