From: lwall@jato.Jpl.Nasa.Gov (Larry Wall)
Newsgroups: alt.sources,comp.unix.questions,comp.lang.perl
Subject: Re: A Perl version of "wall"
Message-ID: <3594@jato.Jpl.Nasa.Gov>
Date: 6 May 90 03:13:11 GMT

In article <KAYVAN.90May5003631@mrspoc.Transact.COM> kayvan@mrspoc.Transact.COM (Kayvan Sylvan) writes:
: In article <264186E0.17B3@tct.uucp> chip@tct.uucp (Chip Salzenberg) writes:
: 
: [... a rather nice version of wall ...]
: 
: 	$_ = `who am i 2>/dev/null`;
: 	chop;
: 	($me) = split;
: 	$me = "Somebody" unless $me;
: 
: Instead of the above, I would do:
: 
: 	($me = getlogin) || (($me) = getpwuid($<)) || ($me = "Somebody");

Granted that the manual says something like that, but it can be shortened,
since || always returns one or the other of its arguments, rather than 0 and 1.
[Gee, I suppose I should document that somewhere...]

I would say

	$me = getlogin || (getpwuid($<))[0] || "Somebody";

(Though, of course, that ()[] presumes patchlevel 18.)  You could even say

	$me = getlogin || (getpwuid($<))[0] || die "Intruder Alert!\n";

Larry
