Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: sh: foo=${bar-baz}; perl: ($foo = $bar) =~ s/^$/baz/; Message-ID: <1990Jul31.013808.3980@iwarp.intel.com> Date: 31 Jul 90 01:38:08 GMT References: <7195@star.cs.vu.nl> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 16 In-Reply-To: maart@cs.vu.nl (Maarten Litmaath) In article <7195@star.cs.vu.nl>, maart@cs (Maarten Litmaath) writes: | Anything better? Remember, the variables could have looooooooong names | you rather wouldn't retype. Is cheating OK? :-) $_ = $bar; $foo = (length) ? $_ : "baz"; Your solution fails on $bar = "\n" (at least). $_ = "Just another "; print $_ .= "Perl hacker," -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/