zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@sunsite.dk
Subject: Re: kinda perl split ...
Date: Tue, 21 Mar 2006 09:10:07 -0800	[thread overview]
Message-ID: <060321091007.ZM5454@torch.brasslantern.com> (raw)
In-Reply-To: <44201CDE.5040406@ulpmm.u-strasbg.fr>

On Mar 21,  4:33pm, Marc Chantreux wrote:
}
} my %user;
} @user{qw( login passwd )} = split /:/;

You can still use "read".

  local -A user
  while IFS=: read 'user['${^=:-login passwd uid gid gecos home shell}']'
  do
    if (( ${user[uid]} > 100 )) { print $user[login] }
  done < /etc/passwd

} http://khatar.phear.org/shell/zshEnum.html

A better way to write "enum":

  enum() {
    integer i=0
    eval integer -g $^@='$[++i]'
  }

Then you don't need "eval $(enum ...)" because enum does the assignments
for you.

You can also do it this way:

  local -a user i; i=( login passwd uid gid gecos home shell )
  while IFS=: read -A user
  do
    if (( ${user[$i[(i)uid]]} > 100 )) { print $user[$i[(i)login]] }
  done < /etc/passwd


  reply	other threads:[~2006-03-21 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-21 13:42 Marc Chantreux
2006-03-21 13:51 ` Dominic Mitchell
2006-03-21 14:22   ` Marc Chantreux
2006-03-21 14:54     ` Dominic Mitchell
2006-03-21 15:33 ` Marc Chantreux
2006-03-21 17:10   ` Bart Schaefer [this message]
2006-03-22 13:12     ` Marc Chantreux
2006-03-22 14:33       ` Bart Schaefer
2006-03-22 15:04         ` Marc Chantreux
2006-03-22 15:18         ` Marc Chantreux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=060321091007.ZM5454@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).