Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!decwrl!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: uppercasing the first letter of the input Message-ID: <9639@jpl-devvax.JPL.NASA.GOV> Date: 25 Sep 90 02:51:55 GMT References: <1990Sep25.002313.24175@fxgrp.fx.com> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 18 In article <1990Sep25.002313.24175@fxgrp.fx.com> grady@fx.com writes: : Is there a better way to uppercase the first letter of the : input than the following: : : perl -pe 's/./($up = $&) =~ tr^a-z^A-Z^; $up/e' : : I don't like using the extra variable. I'd prefer: : : perl -pe 's/./$& =~ tr^a-z^A-Z^/e' : : but the return value of the "tr" expression is the number of matches, : rather than the translated string itself.. Say substr($_,0,1) =~ tr/a-z/A-Z/; Larry