http://www.perlmonks.org?node_id=58438


in reply to Problem with MacPerl

I'm come from a long line of Mac lovers. (I'm looking at my PowerBook G3 running my mail server right now). MacPerl is in my opinion a dastardly half-migration of Perl per se. Things like sleep and @readinlines = <DATAFILE>; do not work as expected if you are coming from a *NIX environment. I am sad to say that sleep is just as dastardly in AppleScript. (as a side note, sleep is also a crappy command in AppleScript but is supposed to be changed in OSX). The reason why sleep does not work is that it cannot break the "command cycle". That si to say it must wait until an empty moment to be run. But it's sleeping so the OS just skips right over its request, the script wakes up because the OS "touched" it and then waits until the OS comes around again. But by that time it's already asleep again! This is obviously not the intended behaviour. An Apple Engineer explained to me at MacWorld that the best thing to do is give it a task that must be waited upon by the OS, so that the suggestion above to do selects and stuff is probably your best short term bet. In that way, you can be doing something in the background that would require the OS to leave and come back to give processor time you would have a better chance of getting your script to run. Or using an extension (I can't remember the name of some right now but you can find them on versiontracker.com) because extensions live in the processor cycle. I know htis is long but one last thing. There is a Scripting Addition that does true mutli-tasking that you could use with Appelscript to create a similar "sleep" behaviour. You can email me at gregs@l90.com is you want more info. HTH CiceroLove