Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: sh: foo=${bar-baz}; perl: ($foo = $bar) =~ s/^$/baz/; Message-ID: <8946@jpl-devvax.JPL.NASA.GOV> Date: 31 Jul 90 22:56:08 GMT References: <7195@star.cs.vu.nl> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 18 In article <7195@star.cs.vu.nl> maart@cs.vu.nl (Maarten Litmaath) writes: : Anything better? Remember, the variables could have looooooooong names : you rather wouldn't retype. I fail to see the name you had to retype in ($foo = $bar) =~ s/^$/baz/; However, if, as is often the case, you know $bar isn't going to have the value "0", it's shorter and much more intuitive to say $foo = $bar || "baz"; as in $home = $ENV{'HOME'} || $ENV{'LOGDIR'} || (getpwuid($<))[7] || die; Larry