Home: Perl Programming Help: Beginner:
Strings question



abuschr
Novice

Aug 20, 2002, 4:25 AM


Views: 1246
Strings question

Is there a way to think about a string as an array?

I mean that if I have a string like this:

my $string = "bla bla bla";

and I want to change the third letter from a to o, how can I do it?

Can I do something like $string[2] = "o" ?


davorg
Thaumaturge / Moderator

Aug 20, 2002, 4:39 AM


Views: 1245
Re: [abuschr] Strings question


Code
substr($string, 2, 1) = 'o';


--
Dave Cross, Perl Hacker, Trainer and Writer
http://www.dave.org.uk/
Get more help at Perl Monks