[Cascavel-pm] Ler posicao do array..

Fernando Oliveira fernandocorrea em gmail.com
Quinta Agosto 23 09:31:30 PDT 2007


perl -F, -MData::Dumper -nale
'if($.==1){@VARs=map{[$_]}@F;next};push@{$VARs[$_]},$F[$_]for 0..$#F;
END{print Dumper \@VARs}' data

2007/8/23, Nelson Ferraz <nferraz em gmail.com>:
>
> > Ex:
> > arquivo:
> > VAR,VAR4,VAR5,VAR1,VAR3..... ( nao estao em ordem e muda de arquivo
> > para arquivo)
> > 4,6,7,8,9,0.....
> > 2,7,4,6,2,0,......
> > 3,57,4,2,44,2,1,4,55,6......
>
> Isso parece um trabalho para o Text::CSV::Simple
>
>          my $parser = Text::CSV::Simple->new;
>          my @data = $parser->read_file($datafile);
>          print @$_ foreach @data;
>
>          # Only want certain fields?
>          my $parser = Text::CSV::Simple->new;
>          $parser->want_fields(1, 2, 4, 8);
>          my @data = $parser->read_file($datafile);
>
>          # Map the fields to a hash?
>          my $parser = Text::CSV::Simple->new;
>          $parser->field_map(qw/id name null town/);
>          my @data = $parser->read_file($datafile);
>
> http://search.cpan.org/~tmtm/Text-CSV-Simple-1.00/lib/Text/CSV/Simple.pm
>
>
>
>
> _______________________________________________
> Cascavel-pm mailing list
> Cascavel-pm em pm.org
> http://mail.pm.org/mailman/listinfo/cascavel-pm
>



-- 
[]'s Fernando
-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://mail.pm.org/pipermail/cascavel-pm/attachments/20070823/5d4fc141/attachment-0001.html 


Mais detalhes sobre a lista de discussão Cascavel-pm