Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Changing the first character of a string. Message-ID: <8569@jpl-devvax.JPL.NASA.GOV> Date: 2 Jul 90 17:23:13 GMT References: <1990Jul2.153957.24671@uvaarpa.Virginia.EDU> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 21 In article <1990Jul2.153957.24671@uvaarpa.Virginia.EDU> worley@compass.com writes: : Of course, there's always: : : $flags =~ s/^./U/; : : (If $flags doesn't contain newlines, or $(whatever) is 0.) If you want to avoid that problem, you can get fancy and say vec($flags,$offset,8) = ord('U'); That will extend the string as necessary. (Of course, it'll extend it with null characters if $offset is greater than the current length...) You could also say $flags =~ s/^[^\0]?/U/; But I still vote for substr. Larry