Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: how to force scalar to be an array?
- X-seq: zsh-users 7942
- From: Andy Spiegl <zsh.Andy@xxxxxxxxx>
- To: ZSH User List <zsh-users@xxxxxxxxxx>
- Subject: Re: how to force scalar to be an array?
- Date: Sat, 28 Aug 2004 09:43:55 +0200
- In-reply-to: <Pine.LNX.4.61.0408271416370.4189@xxxxxxxxxxxxxxxxxx>
- Kinfo: virscan ok
- Kinfo: NoRelay, NoSpam
- Kreccount: 1
- Mail-followup-to: ZSH User List <zsh-users@xxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <20040827154905.GA26846@xxxxxxxxx> <Pine.LNX.4.61.0408271416370.4189@xxxxxxxxxxxxxxxxxx>
> So your only safe bet is to actually assign the scalar to an array, and
> then use subscripting on the array.
But then how would I be able to split the words if there are more than one?
Hm, I think I must be doing something wrong here. Shouldn't it be an
absolutely easy and common task to split a line into its words and then
pick the first one and the rest of them.
In Perl I'd do for example: (just to illustrate what I want to do)
$result=`some_proggie`
@words = split (/\s/, $result);
or maybe:
$result =~ /(\S+)(.*)/;
$first_word=$1;
$rest_words=$2;
--
o _ _ _
------- __o __o /\_ _ \\o (_)\__/o (_) -o)
----- _`\<,_ _`\<,_ _>(_) (_)/<_ \_| \ _|/' \/ /\\
---- (_)/ (_) (_)/ (_) (_) (_) (_) (_)' _\o_ _\_v
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
When women are depressed they either eat or go shopping.
Men invade another country. --- Elayne Boosler
Messages sorted by:
Reverse Date,
Date,
Thread,
Author