[SP-pm] Como pegar o indice dos objetos
Renato Santos
renato.cron at gmail.com
Sun Oct 3 18:57:23 PDT 2010
Uia! Usou ate um each! Legal, mostra como perl pode ser escrito de varias
Formas.
Em out 3, 2010 10:54 PM, "Lucas Moraes" <mineiro at live.be>escreveu:
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.
_______________________________________________
SaoPaulo-pm mailing list
SaoPaulo-pm at pm.org
http://mail.pm.org/mailman/listinfo/saopaulo-pm
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/saopaulo-pm/attachments/20101003/67dc2022/attachment.html>
More information about the SaoPaulo-pm
mailing list