Hi,
A quick question about filtering input in perl.
I have a little program that reads the output of the w command into a hash. It the sorts the records and outputs the results. What I would like to do is filter the initial read on <WHO> so that the only records in the hash are people with an idle time in days.
Is it possible to put a construct in the @Who_Data = <WHO>; so that all the filtering is done in one hit?
The code so far is.
#!/usr/bin/perl
open(WHO,"w -h |"); @Who_Data = <WHO>; my @sorted = map { $_->[0] } sort custom map { [$_, split /:/ ] } @Who_Data;
print @sorted;
sub custom { $a->[0] cmp $b->[0]; }