[SP-pm] Write Binary!

Igor Sutton Lopes igor.sutton em gmail.com
Sexta Abril 27 03:21:22 PDT 2007


Oi Henrique,

On Apr 26, 2007, at 6:07 PM, Henrique Rennó wrote:

> Olá Igor!
>
> Valeu pelo seu código mas apenas mudei o meu para fazer a  
> concatenação dos packeados com formatação "f" e escrever no arquivo  
> assim como você descreveu. Funcionou certinho! Tão simples!

Assim, seguindo a sugestão do Eden, o código final seria:

<code>
use strict;
use warnings;

my @data = (
     [ 0, 1, 2, 3, 4 ],    # linha1
     [ 0, 1, 2, 3, 4 ],    # linha2
     [ 0, 1, 2, 3, 4 ],    # linhaN
);

my $binary_data;
$binary_date .= pack("f*", @$_) for @data;
open my $fh, ">", "/tmp/output.bin" or die $!;
binmode($fh);
print $fh $binary_data;
close $fh or warn $!;
</code>



--
Igor Sutton
igor.sutton em gmail.com



-------------- Próxima Parte ----------
Um anexo em HTML foi limpo...
URL: http://mail.pm.org/pipermail/saopaulo-pm/attachments/20070427/704bf0da/attachment.html 
-------------- Próxima Parte ----------
Um anexo não texto foi limpo...
Nome  : PGP.sig
Tipo  : application/pgp-signature
Tam   : 186 bytes
Descr.: This is a digitally signed message part
Url   : http://mail.pm.org/pipermail/saopaulo-pm/attachments/20070427/704bf0da/attachment.bin 


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