Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: how to force scalar to be an array?



> 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