Path: utzoo!attcan!uunet!snorkelwacker!usc!zaphod.mps.ohio-state.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: Substitution shortcut? Message-ID: <9423@jpl-devvax.JPL.NASA.GOV> Date: 7 Sep 90 00:53:42 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 27 In article Mike.McManus@FtCollins.NCR.com (Mike McManus) writes: : : If I have something like this: : : $a = "hello"; : $b = $a; : $b =~ s/ello/i/; : : ...is there a "short" way to write this? Something like: : : $a = "hello"; : $b = ($a ~ s/ello/i/); : : Seems silly to have to say $b = $a first, but if I gotta, so be it. Just : curious if I've been missing something. Recall that an assignment can be an lvalue. So the idiom is $a = "hello"; ($b = $a) =~ s/ello/i/; This is also quite useful with chop and tr///: chop($HOST = `hostname`); ($host = $HOST) =~ tr/A-Z/a-z/; Larry