http://www.perlmonks.org?node_id=528169


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 /;