[2663] in BarnOwl Developers

home help back first fref pref prev next nref lref last post

Re: [PATCH] add a random zsig function

daemon@ATHENA.MIT.EDU (Kevin Riggle)
Tue Sep 21 00:38:25 2010

Cc: Zev Benjamin <zev@mit.edu>, barnowl-dev <barnowl-dev@mit.edu>
From: Kevin Riggle <kevinr@free-dissociation.com>
To: Anders Kaseorg <andersk@mit.edu>
In-reply-to: <alpine.DEB.2.00.1009210011520.15192@dr-wily.mit.edu>
Date: Tue, 21 Sep 2010 00:38:19 -0400

Excerpts from Anders Kaseorg's message of Tue Sep 21 00:19:37 -0400 2010:
> On Mon, 20 Sep 2010, Zev Benjamin wrote:
> > > +    my $zsig = "@{[$lines[int(rand(scalar @lines))]]}";
> > 
> > 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 
> @lines is empty ‘Use of uninitialized value $zsig in scalar chomp’. 

In fact. :)

> But 
> actually he just traded one warning for another: ‘Use of uninitialized 
> value within @lines in string’.

Oh, these are warnings, not errors.  That explains why I wasn't seeing them.
(Have we considered turning on 'use warnings' and 'use strict' in the BarnOwl
codebase?  I bet that would be a bit of a nightmare, actually. :/)
> 
> 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 
> bikeshedding, for which I apologize.)

Honestly, pointing out issues with my Perl is so far from the bikeshedding I 
was worried about that I almost don't mind it at all.  :-)
> 
> > > +    open my $file, '<', $zsigfile or die "File $zsigfile is 
> > > inaccessible or nonexistent.";
> 
> Including $! in the message would tell the user which problem it is.
> 
Updated patch has been sent.

- Kevin

home help back first fref pref prev next nref lref last post