in reply to array processing
split does not happen automatically, you need to call it. If you're only trying to keep one record of each user who has logged in you could use a hash. So your loop could be:
This will print out a sorted list of users who have logged in, along with the date/time of the last login.my %user_login; while (my $line = <errlog>) { chomp $line; next unless ($line =~ /Login succeeded/); my ($date,$time,$username)=(split(' ',$line))[0,1,6]; $user_login{$username}="$date $time"; } for my $record(sort keys %user_login) { print "$record logged in at $user_login{$record}\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: array processing
by Anonymous Monk on Dec 06, 2005 at 11:19 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 11:34 UTC | |
by inman (Curate) on Dec 06, 2005 at 11:47 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 11:55 UTC | |
Re^2: array processing
by Anonymous Monk on Dec 06, 2005 at 12:41 UTC | |
by tirwhan (Abbot) on Dec 06, 2005 at 12:58 UTC | |
by Anonymous Monk on Dec 06, 2005 at 13:12 UTC | |
by Anonymous Monk on Dec 06, 2005 at 13:31 UTC |