[Israel.pm] pack vs. different architectures
Ephraim Dan
e.dan at F5.com
Tue Feb 22 01:55:10 PST 2005
On Tue, 2005-02-22 at 11:20, Roman M. Parparov wrote:
> my $str =
> pack('a8',$hdr->{id}) .
> pack('f',$hdr->{lat}) .
> pack('f',$hdr->{lon}) .
> pack('f',$hdr->{t}) .
> pack('N',$hdr->{nlev}) .
> pack('N',$hdr->{flag});
> syswrite(DAT,$str);
A style question - why are you calling pack 6 times? The function
prototype for pack is "pack TEMPLATE, LIST".
To me, it's much clearer to write:
my $str = pack( "a8 f f f N N",
$hdr->{id},
$hdr->{lat},
$hdr->{lon},
$hdr->{t},
$hdr->{nlev},
$hdr->{flag}, );
- Ephraim
More information about the Perl
mailing list