[SP-pm] Como pegar o indice dos objetos
Lucas Moraes
mineiro at live.be
Sun Oct 3 18:54:14 PDT 2010
Oi Renato, tudo bem meu codigo ficou assim:
arquivo teste.pl
#!/usr/bin/perl
use strict;
use warnings;
use mod::config;
print "Content-type: text/html\n\n";
my $test = new mod::config;
$test->nome({
nome => 'Lucas',
idade => 23,
cidade => 'Bragança Paulista',
});
$test->imprimir;
arquivo mod/config.pm
package mod::config;
use strict;
use warnings;
use Moose;
has 'nome' => (is => 'rw');
sub imprimir {
my $self = shift;
while(my($indice, $valor) = each(%{$self->nome})){
print $indice . ' = ' . $valor . '<br />';
}
}
1;
Deus é o limite.
-------------- Pr?xima Parte ----------
Um anexo em HTML foi limpo...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20101004/5b98a06e/attachment.html>
More information about the SaoPaulo-pm
mailing list