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 (&lt;&gt;){
    chomp($_);

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

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

    print $_;

    ($zebra == 1 &amp;&amp; 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.
Sed: 45 characters

1~2s/^/\e[40;37m/;2~2s/^/\e[44;37m/;s/$/\e[m/


Usage:

some-command | sed $'1~2s/^/\e[40;37m/;2~2s/^/\e[44;37m/;s/$/\e[m/'