Re: 'sort' command-alternative?
Re: 'sort' command-alternative?
- Subject: Re: 'sort' command-alternative?
- From: John Delacour <email@hidden>
- Date: Fri, 4 Oct 2002 08:45:19 +0100
- Mac-eudora-version: 5.3 alpha
At 7:30 pm -0400 3/10/02, Rob Jorgensen wrote:
At 11:22 PM +0100 10/3/02, John Delacour wrote:
for (sort @array) { print qq($_$return) } '"
paragraphs of result
When I run this, everything is sorted alphabetically except the last
item: loginwindow
It follows Virex 7.1. Is that the expected behavior?
Yes. See sort in perlfunc.pod using the topical script. Bill
Fancher's mod is the neatest to date, though I think we need to get
the links right.
perlfunc is the primary source for info on perl functions.
Here's a case-insensitive way, which also omits the empty lines:
tell app "Finder" to set ls to name of processes
set AppleScript's text item delimiters to {ASCII character 10}
set ls to "" & ls
set AppleScript's text item delimiters to {""}
do shell script "perl -e '
@_ = split /\\n/, q(" & ls & ") ;
for (sort { uc($a) cmp uc($b) } @_) {
/\\w/ and print qq($_$/) }'"
# "{ uc($a) cmp uc($b) }" adds the necessary sort param
# "/\w/ and ..." means "if the line contains a word character, then..."
# "@array = split /$delim/, $string" is eqv to AS text item delimiters
# "\n" is new line ; "$/" is the environment's line terminator
Perl is a language that does not require its users to howl hopelessly
for ten years hoping for its authors to add functionality that
everyone needs and get nothing but bugs or stagnation in return. It
is said that larry wall actually reads all his email!
--JD
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.