in reply to Forcing array context
I want to use a scalar $string in a very C-like way, that is I want to run through the @string character by character, fiddling with chars along the way.Try something like
Then @chars has each character in it. So:my @chars = split //, $string;
or something like that. Then of course you join them together when you're done...foreach my $char (split //, $some_string) { if($char eq " ") { print "it was a space!"; # change all spaces to |s $char = "|"; } }
$string = join("", @chars);
Hope it helps.
jarich
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Forcing array context
by jens (Pilgrim) on Nov 22, 2002 at 05:39 UTC | |
by jarich (Curate) on Nov 22, 2002 at 05:47 UTC | |
by merlyn (Sage) on Nov 22, 2002 at 13:00 UTC | |
by helgi (Hermit) on Nov 22, 2002 at 14:23 UTC |