As to throwing away values, if you want to ignore the first one, just do this: If you're going to ignore the first value, do this:
As to your next part:(undef, $match_I_want) = split /:/, $_, 2;
Sounds like what you really want is this:($user) = split /:/, $_, [1]; ($temp, $foo{$user}) = split /:/, $_, [2];
Finally, what you're doing may be unnecessary. I'm assuming that you're doing a build of /etc/passwd, right? You may also want to look into the getpwnam, getpwuid and related functions and let them take care of the work for you. If you want to read everything from the password file, take a look at getpwent.($user,$name) = split /:/, $_, 2; $name_lookup{$user} = $name;
xoxo,
Andy
--
<megaphone>
Throw down the gun and tiara and come out of the float!
</megaphone>
In reply to Re: Questions about split (indexing /etc/passwd)
by petdance
in thread Questions about split
by blax
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |