[2659] in BarnOwl Developers
Re: [PATCH] add a random zsig function
daemon@ATHENA.MIT.EDU (Anders Kaseorg)
Tue Sep 21 00:19:40 2010
Date: Tue, 21 Sep 2010 00:19:37 -0400 (EDT)
From: Anders Kaseorg <andersk@MIT.EDU>
To: Zev Benjamin <zev@mit.edu>
cc: Kevin Riggle <kevinr@free-dissociation.com>, barnowl-dev@mit.edu
In-Reply-To: <4C982F58.1090303@mit.edu>
On Mon, 20 Sep 2010, Zev Benjamin wrote:
> > + my $zsig =3D "@{[$lines[int(rand(scalar @lines))]]}";
>=20
> Why do you create of a list ref, deference it, and do string
> interpolation on it?
I assume he was trying to address the warning I mentioned earlier when=20
@lines is empty =E2=80=98Use of uninitialized value $zsig in scalar chomp=
=E2=80=99. But=20
actually he just traded one warning for another: =E2=80=98Use of uninitiali=
zed=20
value within @lines in string=E2=80=99.
How about writing something more obvious to handle that case explicitly:
return '' if !@lines;
(There seems to be something about this feature that encourages excessive=
=20
bikeshedding, for which I apologize.)
> > + open my $file, '<', $zsigfile or die "File $zsigfile is=20
> > inaccessible or nonexistent.";
Including $! in the message would tell the user which problem it is.
Anders