in reply to golf anyone? (taking first field)


The following should do what you require:     @a = map{(split)[0]}@a;

As an un-golfed one-liner I would write it like this:     perl -lane 'print $F[0] if @F' file

Update: I see that you added a specific requirement for lines that begin with ":" in one of your follow ups. In Golf that's not fair since it means that we would have to have read all of the other posts before posting a reply.

Anyone interested in posting a Golf challenge should read Tips on Writing a Golf Challenge.

The following handles the special case (the ^ is probably optional):     @a = grep!/^:/,map+(split)[0],@a;

--
John.