#!/usr/bin/perl use strict; use warnings; my $bin = 0b1111_1111_1111; for my $factor (3,5) { # round up to multiple of 4 my $shift = $factor + (-$factor % 4); my $c = $bin >> $shift; $c <<= $shift; printf "%b\n", $c; }