Something like this will do what you are looking for. Of course there are probably other ways of doing this too but this is the first that comes to my mind.my $string = ' this is a string'; my $rep; $string =~ s/(^\s+)/$rep.=':' for(1..length($1)); "$rep"/eg; print $string;
In reply to Re: substitute leading whitespace
by Elijah
in thread substitute leading whitespace
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |