<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2657.73">
<TITLE>RE: [Kc] sort by mod date (Mac OS X specific)</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>JYOUNG79 at kc dot rr dot com wrote:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Sorry for my delayed response.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; but I never could make it work.&nbsp; It kept giving me these errors:</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; *&nbsp; Argument (file name) isn't numeric in numeric comparison (&lt;=&gt;)</FONT>
<BR><FONT SIZE=2>&gt; &gt; &gt; *&nbsp; (62) Use of uninitialized value in string comparison (cmp)</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; The script works for me on a Win32 system. Did you cut and past from </FONT>
<BR><FONT SIZE=2>&gt; &gt; your script or re-type it?</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; I had pasted it.</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; You might see what the following produces:</FONT>
<BR><FONT SIZE=2>&gt; &gt; </FONT>
<BR><FONT SIZE=2>&gt; &gt; opendir(DIR, shift || &quot;/Users/jay/Desktop/Other Stuff/old stuff 4&quot;); </FONT>
<BR><FONT SIZE=2>&gt; &gt; for my $i (grep { !/^\.{1,2}$/ } readdir(DIR)) {&nbsp; print '['. </FONT>
<BR><FONT SIZE=2>&gt; &gt; (stat($i))[9] . &quot;, $i]\n&quot;</FONT>
<BR><FONT SIZE=2>&gt; &gt; }</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; Hmm.&nbsp; I can't seem to make this work.&nbsp; It's giving me this error:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; (19) Use of uninitialized value in concatenation (.) or string</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The debugger is giving me this:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; [1086789289, .DS_Store]</FONT>
<BR><FONT SIZE=2>&gt; [, 3002 copy 2]</FONT>
<BR><FONT SIZE=2>&gt; [, BullsEye Builder]</FONT>
<BR><FONT SIZE=2>&gt; [, BullsEye Builder copy]</FONT>
<BR><FONT SIZE=2>&gt; [, BullsEye Builder-Prefs.txt]</FONT>
<BR><FONT SIZE=2>&gt; [, BullsEye Builder-Prefs.txt old just in case] [, Convert Quark</FONT>
<BR><FONT SIZE=2>&gt; 4 to 6.applescript] [, droplet and applett&nbsp; test] [, dude] [, </FONT>
<BR><FONT SIZE=2>&gt; dude2] [, GA_Template.qxd 1] [, illust1.scpt] [, illust2.scpt] </FONT>
<BR><FONT SIZE=2>&gt; [, illust3.scpt] [, Indigo Proofer X] [, Indigo Proofer X = </FONT>
<BR><FONT SIZE=2>&gt; backup] [, Personal Macro Workbook] [, property test] [, untitled </FONT>
<BR><FONT SIZE=2>&gt; folder] [, 'ΔΆ IndigoPPDs] Use of uninitialized value in </FONT>
<BR><FONT SIZE=2>&gt; concatenation (.) or string at /Volumes/Data 1/Perl Stuff/Garrett's</FONT>
<BR><FONT SIZE=2>&gt; sort example.pl line 3.</FONT>
<BR><FONT SIZE=2>&gt; ...</FONT>
<BR><FONT SIZE=2>&gt; (That last line is repeated 19 times (basically for each item))</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; The debugger points to line 3 as the error:</FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; print '['. (stat($i))[9] . &quot;, $i]\n&quot; </FONT>
<BR><FONT SIZE=2>&gt; </FONT>
<BR><FONT SIZE=2>&gt; It looks like it doesn't want to work with 'stat' for some reason.</FONT>
<BR><FONT SIZE=2>&gt; It might also be this program I'm using (as well as it being on a </FONT>
<BR><FONT SIZE=2>&gt; Mac).&nbsp; I'm sure I'm just missing something simple here with my lack</FONT>
<BR><FONT SIZE=2>&gt; of knowledge, but let me know if you see something I'm missing.</FONT>
</P>

<P><FONT SIZE=2>Given the original error, that's pretty much where I expected the problem to be. Odd that the first call to stat worked. Perhaps it is the odd characters in the subsequent filenames.&nbsp; Quoting filenames on various OS's sometimes works around this. -Though I wouldn't think it'd be necessary for stat... Perhaps give this a try:</FONT></P>

<P><FONT SIZE=2>opendir(DIR, shift || &quot;/Users/jay/Desktop/Other Stuff/old stuff 4&quot;); </FONT>
<BR><FONT SIZE=2>for my $i (grep { !/^\.{1,2}$/ } readdir(DIR)) {</FONT>
<BR><FONT SIZE=2>&nbsp; print '['. (stat('&quot;'.$i.'&quot;'))[9] . &quot;, $i]\n&quot;;</FONT>
<BR><FONT SIZE=2>}</FONT>
</P>

<P><FONT SIZE=2>If that gives more promising results, the modified original script would look like:</FONT>
</P>

<P><FONT SIZE=2>opendir(DIR, shift || &quot;/Users/jay/Desktop/Other Stuff/old stuff 4&quot;) or die $!;</FONT>
<BR><FONT SIZE=2>print map { &quot;$_-&gt;[1]\n&quot; } </FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sort { $a-&gt;[0] &lt;=&gt; $b-&gt;[0] || $a-&gt;[1] cmp $b-&gt;[1] }</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; map { [ (stat('&quot;'.$_.'&quot;'))[9], $_ ] }</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; grep { !/^\.{1,2}$/ }</FONT>
<BR><FONT SIZE=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; readdir(DIR)</FONT>
</P>
<BR>

<P><FONT SIZE=2>If that doesn't work, we might try looking at adding a:</FONT>
</P>

<P><FONT SIZE=2>use <A HREF="File::Spec::Functions" TARGET="_blank">File::Spec::Functions</A> qw(:ALL);</FONT>
</P>

<P><FONT SIZE=2>and replacing stat($_) with stat(canonpath(rel2abs($_)))</FONT>
</P>
<BR>
<BR>

<P><FONT SIZE=2>I hope one of our Mac Perl folks will take a look at this...</FONT>
</P>

<P><FONT SIZE=2>--</FONT>
<BR><FONT SIZE=2>Garrett Goebel</FONT>
<BR><FONT SIZE=2>IS Development Specialist</FONT>
</P>

<P><FONT SIZE=2>ScriptPro&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Direct: 913.403.5261</FONT>
<BR><FONT SIZE=2>5828 Reeds Road&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Main: 913.384.1008</FONT>
<BR><FONT SIZE=2>Mission, KS 66202&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Fax: 913.384.2180</FONT>
<BR><FONT SIZE=2>www.scriptpro.com&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; garrett@scriptpro.com</FONT>
</P>

</BODY>
</HTML>