Guest User

Untitled

a guest
Nov 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2.  
  3. use strict;
  4.  
  5. if($#ARGV < 0) {
  6. print "Usage: $0 <ProtocolDescription.xml>\n";
  7. exit 1;
  8. }
  9.  
  10. if(! -e $ARGV[0]) {
  11. print "File $ARGV[0] not found\n";
  12. exit 1;
  13. }
  14.  
  15. if(! open(XML,"<$ARGV[0]")) {
  16. print "Unable to open file $ARGV[0]\n";
  17. exit 1;
  18. }
  19.  
  20. my %commands;
  21. while(<XML>) {
  22. if(/command\s+name="(.+)".*source="(.+)"/i) {
  23. my ($c,$s)=(lc($1),lc($2));
  24. $commands{$s}=[] unless(defined($commands{$s}));
  25. push(@{$commands{$s}},$c);
  26. }
  27. }
  28.  
  29. foreach my $s (keys %commands) {
  30. print "Source: $s\n";
  31. my @c=sort(@{$commands{$s}});
  32. foreach my $command (@c) {
  33. print " $command\n";
  34. }
  35. }
Add Comment
Please, Sign In to add comment