#!/usr/bin/perl -w use strict; sub is_odd { unpack "%1b*", pack "b*", shift } for(1..10) { print is_odd("1" x $_), "\n"; } __END__ 1 0 1 0 1 0 1 0 1 0