in reply to substitute leading whitespace
There is more than one way to do what you would like to do. Surely somebody else will post another way. I like $string =~ s/^(\s+)/':' x length $1/e;