#!/bin/perl -w use strict; use XML::Twig; my $twig= new XML::Twig; $twig->parse( \*DATA); # build the twig my $root= $twig->root; # get the root of the twig (stats) my @vob_not = $root->children( sub { my $elt= shift; !$elt->att( 'vob')}); my @vob_none = $root->children( q{player[@vob="none"]} ); my @vob_letter = $root->children( q{player[@vob=~/^[a-z]$/]}); @vob_letter = sort { $a->att( 'vob') cmp $b->att( 'vob') } @vob_letter; my %letters= map { $_->att( 'vob') => 1 } @vob_letter; print "No attribute or vob=none\n", "-" x 20, "\n"; foreach my $player (@vob_not) { printf( "%-20s\n", $player->field( 'name')); } foreach my $player (@vob_none) { printf( "%-20s....none\n", $player->field( 'name')); } print "\n", join( ', ', sort keys %letters), "\n", "-" x 20, "\n"; foreach my $player (@vob_letter) { printf( "%-20s....%1s\n", $player->field( 'name'), $player->att( 'vob')); } __DATA__ Houston, Allan69 Sprewell, Latrell69 Ewing, Patrick49 Johnson, Larry57 Camby, Marcus48 Thomas, Kurt677.9 Ward, Charlie597.5 Wallace, John556.6 Childs, Chris615.3 Duncan, Tim6623.1 Robinson, David6817.1