in reply to Help with substitution - - 15 Characters from the left
It took a few minutes, but this looks like a good prototype for your needs. You will likely need to adjust the tests on the position variable $i to fit your need more precisely...
This prints:use strict; my $str = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n'; print "$str\n"; my $i = 0; $str =~ s/(.)/$i++;($1 ne ',' or $i>15 && $i<25) ? $1 : '#'/ge; print "$str\n";
I used '#' instead of "\t" for demo purposes so things would line up nicely in the print test.a,b,c,d,e,f,g,h,i,j,k,l,m,n a#b#c#d#e#f#g#h,i,j,k,l,m#n
Note: along the way I tried using pos instead of $i, but apparently it is undefined while still in the right side of the s///. Update: Hofmator is correct to say I am wrong to imply that pos would work outside the s///. pos is not set at all for s///.
Note 2: I offer this as a solution to the problem as you described it but it seems very odd that you would have a list of companies with names that are exactly 10 characters long.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Help with substitution - - 15 Characters from the left
by La12 (Sexton) on Aug 14, 2001 at 00:06 UTC | |
|
Re: Re: Help with substitution - - 15 Characters from the left
by Hofmator (Curate) on Aug 14, 2001 at 12:06 UTC |