perlquestion
Cody Pendant
I'm reading a list of files from a folder with readdir().
<P>
I'm not in charge of the naming conventions here, I have to take what I can get.
<P>
The files are named with leading digits. The digits are good. I'd be happy to keep them in the order of the leading digits.
<P>
But my readdir() produces an array in a weird order for two files named with hypens and numbers elsewhere in the string: Here's the stretch from 50 to 60:
<P>
50doppelgangland.html<br>
51enemies.html<br>
52earshot.html<br>
53choices.html<br>
54prom.html<br>
57freshman.html<br>
58livingconditions.html<br>
<b>55</B>grad-1.html<br>
<b>56</B>grad-2.html<br>
59theharshlightofday.html<br>
60fearitself.html<br>
<P>
Now I've solved my problem by doing a
<code>@listoffiles = sort {$a <=> $b} @listoffiles;</code>, and it appears that the spaceship operator parses the files for usable numbers at the start and ignores the rest, so they come out:
<P>
50doppelgangland.html<br>
51enemies.html<br>
52earshot.html<br>
53choices.html<br>
54prom.html<br>
55grad-1.html<br>
56grad-2.html<br>
57freshman.html<br>
58livingconditions.html<br>
59theharshlightofday.html<br>
60fearitself.html<br>
<br>
<P>
so, not really urgent, but what the hell was going on before? It's a LINUX server.
<BR>
--
<BR>
<code>
($_='jjjuuusssttt annootthheer
pppeeerrrlll haaaccckkeer')=~y/a-z//s;print;</code>