Zebra stripe command output

I have a script:

$cat ~/zebra.pl #!/bin/perl use Term::ANSIColor;$Term::ANSIColor::EACHLINE = "\n";

my $zebra = 1; # Are zebras black with white stripes, or white with black stripes?! my$black = color('white on_black');
my $blue = color('white on_blue'); while (<>){ chomp($_);

$zebra =$zebra == 1 ? 0 : 1;

($zebra == 1 && print$blue) || print $black; print$_;

($zebra == 1 && print$black) || print $blue; print "\n"; } print color('reset'); Usage: some-command | zebra The output consists of alternating lines that have black and blue backgrounds, respectively. The script seems needlessly long and complex. I'm wondering how much shorter it could be. • Actually Perl also can do it in 31 characters: some-command | perl -pe '$_="\e[4".$.%2*4 .";37m$_\e[m"'. So I can't really see where the actual challenge is. Apr 9 '13 at 15:47