develooper Front page | perl.perl5.porters | Postings from August 2001

Re: pack "b*" isn't dwim enough

Thread Previous | Thread Next
From:
John L. Allen
Date:
August 23, 2001 10:26
Subject:
Re: pack "b*" isn't dwim enough
Message ID:
Pine.SOL.3.91.1010823132353.14400A-100000@gateway.grumman.com


On Thu, 23 Aug 2001, H.Merijn Brand wrote:

> Though I did read the doc's and used it more than once, I keep trying to do
> 
> use integer;
> my @bar = map { rand 1 } ( 0 .. 100 );
> my $foo = pack "b*", @bar;
> 
> where I should have used
> 
> my $foo = pack "b*", join "", @bar;

Aside from that point, didn't you really mean to do this

   my @bar = map { int rand 2 } ( 0 .. 100 );

since rand() isn't affected by use integer; ?  

John

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About