<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></head><body >But after programming heavily in Perl for 22 years (!!!) I can safely say I pretty much have the quirks and syntax oddities nailed. This is the first time in a long time something like this one has bit me, and it's understandable because I rarely use the glob op.<div><br></div><div>If you don't like all the weirdness, the beauty of Perl is you can instead just program it as though it was C without malloc. I like choice.</div><div><br></div><br><br>-------- Original message --------<br>From: Sean Walberg <sean@ertw.com> <br>Date:2014/02/02  20:00  (GMT-06:00) <br>To: Continuation of Round Table discussion <roundtable@muug.mb.ca> <br>Subject: Re: [RndTbl] strange race condition on file entries <br><br><div dir="ltr">While I will always manage my life by the three great virtues, I must thank you for reminding me why I gave up slinging Perl. DWIM and all the sigils drive a man to an early grave, or at least a lot of nights debugging.<div>
<br></div><div>Sean</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Feb 2, 2014 at 1:10 PM, Trevor Cordes <span dir="ltr">&lt;<a href="mailto:trevor@tecnopolis.ca" target="_blank">trevor@tecnopolis.ca</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I forgot to post what *does* work. &nbsp;There are a few different<br>
ways.<br>
<br>
You can force the glob to return a list (hence no caching/iterating):<br>
<br>
if (!@{[&lt;$prefix-*&gt;]}) {<br>
<br>
That's sure ugly, but it makes sense. &nbsp;[] forces the &lt;&gt; to return list<br>
and turns it into an anon array-ref. &nbsp;@ then derefs. &nbsp;{} is required by<br>
the parser to make sense of it all. &nbsp;!@ then does its normal thing of<br>
meaning "if there are zero elements in this array".<br>
<br>
You could also force it to list by assigning to an array:<br>
<br>
if (!(@a=&lt;$prefix-*&gt;)) {<br>
<br>
But I hate using temp vars when we don't need to; when the results are<br>
throwaway.<br>
<br>
Strangely, using the normal "we want a list" syntax of just putting ()<br>
around the expression doesn't work in this case. &nbsp;I'm not sure why:<br>
<br>
if (!(&lt;$prefix-*&gt;)) { &nbsp;# doesn't work<br>
<br>
Also strangely, while perl has a "scalar" function to force a scalar<br>
(non-list) result, it doesn't have a "list" or "array" function to<br>
force a list. &nbsp;The scalar docs say list isn't necessary as it's usually<br>
the default/implied or can be forced with (). &nbsp;Woops, looks like I<br>
found a corner case.<br>
<br>
Ya, I could have been certain everything worked in the first place by<br>
doing opendir and iterating through the results, like one would in<br>
C, but the whole purpose of using perl is to do as much as possible in<br>
as few characters and lines. &nbsp;Laziness is the #1 programmer virtue,<br>
according to L.Wall and R.Schwarz.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Sean Walberg &lt;<a href="mailto:sean@ertw.com" target="_blank">sean@ertw.com</a>&gt;&nbsp; &nbsp; <a href="http://ertw.com/" target="_blank">http://ertw.com/</a>
</div>
</body>