Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Build your array with push

by blazar (Canon)
on Feb 06, 2006 at 08:11 UTC ( #528169=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Build your array with push
in thread Build your array with push

That style of code is totally ugly and unusable [...] You should use the following coding style instead:

No, no, no! Yours is better than the previous alternatives but one may still get confused when swapping bits. And all those calls to chr, oh my! Now pack can do all this for cheap. Thus you should use the following coding style instead:

push @Hibbs_Daglish_Schwartz_Vroom, pack qw/(B8)* 01010110 01110010 01101111 01101111 01101101 /;

Except that one would almost certainly want to write a specialized sub to do this, should he later change his mind with respect to the order in which to store bits into chars, chars into strings and strings into the array:

sub insert (\@@) { my $arr=shift; push @$arr, pack '(B8)*', @_; } # ... insert @Hibbs_Daglish_Schwartz_Vroom, qw/ 01010110 01110010 01101111 01101111 01101101 /;


Comment on Re^3: Build your array with push
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://528169]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2014-04-20 11:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls