Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!usc!snorkelwacker!bu.edu!orc!inews!iwarp.intel.com!psueea!parsely!agora!markb From: markb@agora.uucp (Mark Biggar) Newsgroups: comp.lang.perl Subject: Re: Changing first character of a string Message-ID: <1990Jun30.064340.529@agora.uucp> Date: 30 Jun 90 06:43:40 GMT References: Reply-To: markb@.UUCP (Mark Biggar) Organization: Betazoid Central Lines: 17 In article sean@ms.uky.edu (Sean Casey) writes: >Does anyone know of a better way to change the first character of string >$flags to 'S'? The only way I've figured out so far is: > > $flags =~ s/(.)(.*)/S$2/; > >Gotta be a better way. substr($flag,0,1) = 'S'; $flag =~ s/^./S/; $flag = 'S' . substr($flag,1,65535); @flag = split(//,$flag);shift @flag;unshift(@flag,'S');$flag = join('',@flag); last one :-) Perl's maternal uncle Mark Biggar