in reply to Re: Re: Forcing array context
in thread Forcing array context
It kinda depends on what you're trying to do, but I think this might help. (Note that you can also replace with the empty string).my $string = "This is a very long string"; foreach (0..length($string)) { if(substr($string, $_, 1) eq " ") { # Replace this position (space) with a "|" substr($string, $_, 1, "|"); } } print $string;
Hope it does.
jarich
Update: forgot the length. ;)
|
|---|