use strict; use warnings; use feature qw{ say }; my $sep = sub { say q{-} x 24; }; my $baseStr = q{{0,f}}; $sep->(); foreach my $width ( 3 .. 6 ) { say qq{Width - $width}; my $globStr = $baseStr x $width; my @bitStrs = map { pack q{H*}, $_ } glob $globStr; say unpack qq{B@{ [ $width * 4 ]}}, $_ for @bitStrs; say q{Element 2 - }, unpack qq{B@{ [ $width * 4 ]}}, $bitStrs[ 2 ]; say q{Element 6 - }, unpack qq{B@{ [ $width * 4 ]}}, $bitStrs[ 6 ]; say q{E. 2 & E. 6 - }, unpack qq{B@{ [ $width * 4 ]}}, $bitStrs[ 2 ] & $bitStrs[ 6 ]; $sep->(); }