#!/usr/bin/perl -w use strict; while () { my @bits = split /1/; # every string starts with a 1, so # pop the first zero off of @bits pop @bits; print join( ",", @bits ), "\n"; }; __DATA__ 1000000000000100000000000000100