| I need to extact the user name of every user who is logged in | /var/log/maillog.I just want the user name and every one must be present | just one time. | Now I can extract all the strings with the user name and every name is | repeated many times.What can I do?Thanks a lot
Make each user the key of a hash, as follows: $_ = q( Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy00 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy01 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy05 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy01 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy00 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy02 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy05 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy01 Apr 21 01:03:01 pandora ipop3d[28245]: Login user=holy00 ); for (split/\n/) {s~(.+user=)(.+)~$2~; $users{$_} = x} for (sort keys %users) {print "$_$/"} (ie. Make an array of paragraphs (if necessary), extract the user pattern from each item and make it the key of the hash %users with value x or anything. A key cannot be duplicated. Sort the keys if you want.) JD