Perl and World of Warcraft (WoW).

120

This blog will discuss how to use the Perl module Games::WoW::Armory to print both character name and current level for all members of a given guild.

The following Perl script will build a .csv file named guild.csv “,” delimited  containing both character names and current level for all members of a given guild in World of Warcraft (WoW).

#!/usr/bin/perl -w

###############################################
#This script will connect to the wowarmory.com#
#site and display level and name of members   #
#of a particular guild.                       #
###############################################

# Load required modules.
use strict;
use Games::WoW::Armory;
use FileHandle;

#declare variables
my @name;
my @race;
my @level;
my @guild;
my @gender;
my @faction;
my @lmodified;
my @class;

# Create new Games::Wow::Armory object.
my $armory = Games::WoW::Armory->new();

$armory->search_character( { realm     => ‘anvilmar’,
                             character => ‘draxxus’,
                             country   => ‘US’ } );

#set characteristic to it’s corresponding array
@name = $armory->character->name;
@race = $armory->character->race;
@level = $armory->character->level;
@guild = $armory->character->guildName;
@gender = $armory->character->gender;
@faction = $armory->character->faction;
@lmodified = $armory->character->lastModified;
@class = $armory->character->class;

#get guild members
my $armory2 = Games::WoW::Armory->new();
$armory2->search_guild( { realm         => ‘anvilmar’,
                          guild         => “@guild”,
                          country       => ‘US’ } );

#open file handle and write character stats
my $fh = new FileHandle;
        if ($fh->open(“> guild.csv”)) {

# Print Character’s stats.
        foreach my $member (@{$armory2->guild->members}){
        my @members = $member->name;
        print $fh $member->name;
        print $fh “,”;
        print $fh $member->level;
        print $fh “,n”;
                }
        }
$fh->close;

After running the script, it will create a file named guild.csv in the directory it is executed from.  Then you can open the file in spreadsheet for OpenOffice.

 Note:  The following 3 things are required to use the script:

      1.  Realm (i.e. name of server your character is on).

     2. Guild – Name of the guild your character is a member of.

     3. Country – The country code of the server you play on.

 Planned Improvements:  Currently, you must hard-code the realm, guild, and country code in the script.  I plan to make those command-line arguments in the future.  I also plan to be able to print more guild member stats.  As of right now, you can only print the character name and level for ALL guild members due to a limitation in the Games::WoW::Armory module.  I have an idea for a work-a-round that I think will work but haven’t gotten around to coding it yet.

Disclaimer:  This blog entry comes with NO expressed warranty, guarantee, support, or maintenance of any kind!  Use at your own risk!   

Thanks for reading and happy spying on your fellow WoW guildees.