Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!hp4nl!star.cs.vu.nl!maart From: maart@cs.vu.nl (Maarten Litmaath) Newsgroups: comp.lang.perl Subject: Re: sh: foo=${bar-baz}; perl: ($foo = $bar) =~ s/^$/baz/; Message-ID: <7207@star.cs.vu.nl> Date: 1 Aug 90 05:04:40 GMT References: <7195@star.cs.vu.nl> <8946@jpl-devvax.JPL.NASA.GOV> Sender: news@cs.vu.nl Reply-To: maart@cs.vu.nl (Maarten Litmaath) Organization: VU Dept. of Computer Science, Amsterdam, The Netherlands Lines: 31 In article <8946@jpl-devvax.JPL.NASA.GOV>, lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) writes: )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/; Precisely the point! I wanted to circumvent some obvious approach like: length($foo = $bar) || ($foo = 'baz'); ...taking which one has to retype `$foo'. )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; Thanks for this suggestion. In general, however, one seems to be stuck to the `obvious solution'. (Thanks for pointing out the problem with my initial hack, Randal.) -- "and with a sudden plop it lands on usenet. what is it? omigosh, it must[...] be a new user! quick kill it before it multiplies!" (Loren J. Miller)