anyone have a snippet to send a list to perl all really want to do is have perl sort the list for me
I have a giant list of numbers that need to be sorted.
thanks
mm
anyone have a snippet to send a list to perl all really want to do is have perl sort the list for me
I have a giant list of numbers that need to be sorted.
thanks
mm
Would this be any help? http://bbs.applescript.net/viewtopic.php?id=24207
Edit: Regarding Perl (or nearly any command line tool), you can make your list into a string (separated by linefeeds) and pipe it into Perl, then use Perl to manipulate stdin (e.g., split it into an array).
Bruce,
thank you so much you have no idea how much time that saved me in trying to figure it out…
only now I get an out of memory error and I think thats because it returns the sorted list as paragraphs rather than an list …
do you know of a way to have it return the result as an array ?
thanks
mm
You could try dumping the output into a file and reading it in (using delimiter
).
well this seems to work but I’m still getting out of memory errors
set theList to {2, 5, 3, 337, 9, 3, 1}
set tid to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
set theList to "" & theList
set AppleScript's text item delimiters to tid
do shell script "perl -e 'print join(\",\",sort {$a <=> $b } (" & quoted form of theList & "));'"
set theList to the result
set AppleScript's text item delimiters to ","
set theList to text items of theList as list
set AppleScript's text item delimiters to tid
return theList
mm