find-unused-accounts.pl 710 B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/perl
  2. use XML::Simple;
  3. use warnings;
  4. use strict;
  5. use Data::Dumper;
  6. my $xml = XML::Simple->new();
  7. my $users = $xml->XMLin("data/user.xml", KeyAttr => {});
  8. my %l;
  9. # Snarf through the XML data. Build a hash:
  10. # username => lastuse
  11. # Only for users with no items and no money.
  12. # For some reason last_use is floating point so let's fix that.
  13. foreach my $user (@{$users->{user}}) {
  14. if ($user->{'used_stalls'} == 0 && $user->{'money'} == 0) {
  15. $user->{'last_use'} = 0 unless ($user->{'last_use'});
  16. $l{ $user->{'name'} } = int($user->{'last_use'});
  17. }
  18. }
  19. print("Last used\t\t\tUsername\n");
  20. foreach ( sort { $l{$a} cmp $l{$b} || $a cmp $b } keys %l ) {
  21. print gmtime($l{$_}) . "\t$_\n";
  22. }