I'm getting input from the `last` command, putting it into
@lastfile and parsing it up into these bits of info for each user on our system:
username
real name
# of logins
total time
average time
I've built an array that looks like:
$USER[$i]->{username} = "jbarker";
$USER[$i]->{realname} = "Jim Barker";
$USER[$i]->{logins} = 25;
$USER[$i]->{totaltime} = "3:15:25";
$USER[$i]->{average} = 125;
#this is minutes
So the i'th element represents a user. What I need to know is this: Is there any reasonably easy way to sort this array? For example, what if I want to sort the array by average time, or by total time, or by username? Thanks for any help.
Comments
you could check the function sort of perl
you can sort by keys or by values
Carlos
: I'm getting input from the `last` command, putting it into @lastfile and parsing it up into these bits of info for each user on our system:
:
: username
: real name
: # of logins
: total time
: average time
:
: I've built an array that looks like:
:
: $USER[$i]->{username} = "jbarker";
: $USER[$i]->{realname} = "Jim Barker";
: $USER[$i]->{logins} = 25;
: $USER[$i]->{totaltime} = "3:15:25";
: $USER[$i]->{average} = 125; #this is minutes
:
:
: So the i'th element represents a user. What I need to know is this: Is there any reasonably easy way to sort this array? For example, what if I want to sort the array by average time, or by total time, or by username? Thanks for any help.
:
:
:
: