<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"><<a href="mailto:trevor@tecnopolis.ca" target="_blank">trevor@tecnopolis.ca</a>></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. 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 (!@{[<$prefix-*>]}) {<br>
<br>
That's sure ugly, but it makes sense. [] forces the <> to return list<br>
and turns it into an anon array-ref. @ then derefs. {} is required by<br>
the parser to make sense of it all. !@ 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=<$prefix-*>)) {<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. I'm not sure why:<br>
<br>
if (!(<$prefix-*>)) { # 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. The scalar docs say list isn't necessary as it's usually<br>
the default/implied or can be forced with (). 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. 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 <<a href="mailto:sean@ertw.com" target="_blank">sean@ertw.com</a>> <a href="http://ertw.com/" target="_blank">http://ertw.com/</a>
</div>