> Jenda Krynicky wrote: > > > > "John W. Krahn" <[EMAIL PROTECTED]> suggested: > > > my @s = split //, $s; > > > > > > my @s = unpack 'a' x length $s, $s; > > > > > > my @s = $s =~ /./gs; > > > > > > push @s, substr $s, $_, 1 for 0 .. length $s - 1; > > > > > > push @s, chr vec $s, $_, 8 for 0 .. length $s - 1; > > > > Also > > > > unshift @s, chop($s) while $s ne ''; > > > > ;-) > > > > But as Japhy said, stick with the first. We were just playing ;-) > > > > And to get the $i-th character : > > > > $char = substr $s, $i, 1; > > > > or even to change the $i-th char : > > > > substr( $s, $i, 1) = 'X'; >
and John suggested : > Or > > substr $s, $i, 1, 'X'; Wow did not know this one works (could find it in docs, but ...) I think though the first syntax is readable. Though a bit strange if you're used to more orthogonal languages. Maybe ... what about writing it like this : substr $s, $i, 1 => 'X'; I guess this looks even better ... and doesn't force you to put the braces around the params of substr like substr ($s, $i, 1) = 'X'; It's easy though to get confused and try to use substr $s, $i => 'X'; to change the part of string $s starting with $i-th character to 'X'. Jenda =========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ========== There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain. I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]