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