User:Cisox/Scripts

Most of my scripts are written in Perl or Python. I do all of my development in Linux, however, if you are going to run these in Windows you will need to download a version of Perl or Python for Windows. I would suggest Python.org or Active Python for Python on Windows, and Active Perl for Perl on Windows. I can't give any support for these packages, I just know they work.

item2wiki.pl

 * Language: Perl
 * Description: This script takes an item id (such as 30040) and generates code for the wiki page.


 * Example: perl item2wiki.pl 30040


 * Dependencies: XML::Simple, LWP


 * License: GPLv2


 * Updates:


 * I've created a website for the tool. Simply point your browser to http://odoshq.net/item2wiki.php?i=&lt;itemid&gt; and you will be presented with the wiki source of the item.


 * Quirks:
 * item_tooltip.xml from the Armory doesn't include all of the effects on items. I've tried getting this information from several sources, but they all either didn't have the information, was also missing the effect, or didn't have it in a usable state.


 * Not all of the tooltip properties are available in the sources I have. The solution to this problem is simply finding more item databases that can be exported to XML.

use XML::Simple; use LWP;
 * 1) !/usr/bin/perl

my $usage = "Usage:  [Verbose]\n"; my $itemid = shift or die $usage; my $verbose = shift;

my $armory_url = "http://armory.worldofwarcraft.com/item-tooltip.xml?i=$itemid"; my $ii_url = "http://armory.worldofwarcraft.com/item-info.xml?i=$itemid"; my $alk_url = "http://wow.allakhazam.com/cluster/item-xml.pl?witem=$itemid";
 * 1) Sources ###

my %tooltip = ('float'=>'right', 'width'=>'18em', 'itemid' => $itemid); my %category_areas; my $browser = LWP::UserAgent->new; my @source; my @categories; my $disenchant; my $class;
 * 1) Define Variables ###

verbose("Retrieving XML Data from Armory Item-Tooltip"); my $armory_response = $browser->get($armory_url,	'Accept' => 'text/xml,application/xml,application/xhtml+xml;q=0.9,text/plain',	'Accept-Language' => 'en-us;q=0.5',	'Accept-Charset' => 'ISO-8559-1,utf-8;q=0.7,*;q=0.7',	'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4' );
 * 1) Retrieve XML Data from Sources ###

verbose("Retrieving XML Data from Armory Item-Info"); my $ii_response = $browser->get($ii_url,	'Accept' => 'text/xml,application/xml,application/xhtml+xml;q=0.9,text/plain',	'Accept-Language' => 'en-us;q=0.5',	'Accept-Charset' => 'ISO-8559-1,utf-8;q=0.7,*;q=0.7',	'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4' );

verbose("Retrieving XML Data from Allakhazam"); my $alk_response = $browser->get($alk_url,	'Accept' => 'text/xml,application/xml,application/xhtml+xml;q=0.9,text/plain',	'Accept-Language' => 'en-us;q=0.5',	'Accept-Charset' => 'ISO-8559-1,utf-8;q=0.7,*;q=0.7',	'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4' );

my $armory_content = $armory_response->content; my $ii_content = $ii_response->content; my $alk_content = $alk_response->content;

my @quality = ('Poor', 'Common', 'Uncommon', 'Rare', 'Epic', 'Legendary'); my @bind = ('', 'BoP', 'BoE', 'BoU', 'Quest'); my @slots = ('Non-Equip', 'Head', 'Neck', 'Shoulders', 'Shirt', 'Chest', 'Waist', 'Legs', 'Feet', 'Wrist', 'Hand', 'Finger', 'Trinket', 'One-Hand', 'Off Hand', 'Ranged', 'Back', 'Two-Hand', 'Bag', 'Tabard', 'Main Hand', 'Off Hand', 'Held in Off Hand', 'Projectile', 'Thrown', 'Ranged', 'Quiver', 'Relic'); my @dmgtype = ('', 'Holy', 'Fire', 'Nature', 'Frost', 'Shadow', 'Arcane'); my @attributes = ('bonusStrength', 'bonusAgility', 'bonusStamina', 'bonusIntellect', 'bonusSpirit', 'fireResist', 'natureResist', 'frostResist', 'shadowResist', 'arcaneResist'); my %attributes_hash = ('bonusStrength' => 'Strength', 'bonusAgility' => 'Agility', 'bonusStamina' => 'Stamina', 'bonusIntellect' => 'Intellect', 'bonusSpirit' => 'Spirit', 'fireResist' => 'Fire Resistance', 'natureResist' => 'Nature Resistance', 'frostResist' => 'Frost Resistance', 'shadowResist' => 'Shadow Resistance', 'arcaneResist' => 'Arcane Resistance'); my @weapon_plural = ('Axe' => 'Axes', 'Bow' => 'Bows', 'Crossbow' => 'Crossbows', 'Fishing Pole' => 'Fishing Poles', 'Fist Weapon' => 'Fist Weapons', 'Gun' => 'Guns', 'Mace' => 'Maces', 'Polearm' => 'Polearms', 'Staff' => 'Staves', 'Sword' => 'Swords', 'Dagger' => 'Daggers', 'Thrown' => 'Thrown Weapons', 'Wand' => 'Wands'); my @reputation = ('Hated', 'Hostile', 'Unfriendly', 'Neutral', 'Friendly', 'Honored', 'Revered', 'Exalted'); my @triggers = ('Use', 'Equip', 'Chance on Hit'); my @dropRate = ('None', 'Rare', 'Low', 'Medium', 'High', 'Guaranteed'); my @classes = (, 'Container', 'Weapon', 'Gem', 'Armor', 'Reagent', 'Projectile', 'Trade Goods', , 'Recipe', , 'Quiver', 'Quest', 'Key', , 'Miscellaneous'); my @classification = ('', 'Elite', 'Rare Elite', 'Boss', 'Rare');
 * 1) Define Pre-Defined Variables ###

verbose("Parsing Item"); my $xml = new XML::Simple; my $armory_data = $xml->XMLin($armory_content, 'SuppressEmpty' => undef); my $ii_data = $xml->XMLin($ii_content, 'SuppressEmpty' => undef); my $alk_data = $xml->XMLin($alk_content, 'SuppressEmpty' => undef);
 * 1) Start Parsing Data ###

my $item_tooltip = $armory_data->{'itemTooltips'}->{'itemTooltip'}; my $ii_item = $ii_data->{'itemInfo'}->{'item'};

verbose("Icon"); my @sp = split(/\//, $alk_data->{'icon'}); my $icon = pop(@sp); my @sp = split(/\./, $icon); my $icon = shift(@sp); $tooltip{'icon'} = $icon;
 * 1) Parse Icon ###

verbose("Stack"); if($item_tooltip->{'stackable'}) {	$tooltip{'stack'} = $item_tooltip->{'stackable'}; }
 * 1) Parse Stack ###

verbose("Name"); $tooltip{'name'} = $item_tooltip->{'name'};
 * 1) Parse Name ###

verbose("Quality"); $tooltip{'quality'} = $quality[$item_tooltip->{'overallQualityId'}]; push(@categories, $tooltip{'quality'} . " Items");
 * 1) Parse Quality ###

verbose("Bind & QItem"); if(defined($item_tooltip->{'bonding'})) {	if($item_tooltip->{'bonding'} eq "4") {		$tooltip{'qitem'} = 1; }	else {		if($item_tooltip->{'bonding'} ne "0") {			$tooltip{'bind'} = $bind[$item_tooltip->{'bonding'}]; }	} }
 * 1) Parse Bind and QItem ###

verbose("Duration");
 * 1) Parse Duration ###
 * 1) Not Stored in Sources ###

verbose("Unique & Unique-EQ"); if(defined($item_tooltip->{'maxCount'})) {	if(ref($item_tooltip->{'maxCount'}) eq "ARRAY") {		$tooltip{'unique'} = ""; }	else {		if($item_tooltip->{'maxCount'}->{'content'}) {			$tooltip{'unique'} = $item_tooltip->{'maxCount'}->{'content'}; }
 * 1) Parse Unique and Unique-EQ ###

if($item_tooltip->{'maxCount'}->{'uniqueEquippable'}) {			$tooltip{'unique-eq'} = 1; }	} } verbose("QBegin"); if(defined($item_tooltip->{'startQuestId'})) {	$tooltip{'qbegin'} = 1; }
 * 1) Parse QBegin ###

verbose("Type & Slot & Bag"); if(defined($item_tooltip->{'equipData'})) {	if(defined($item_tooltip->{'equipData'}->{'subclassName'})) {		$tooltip{'type'} = $item_tooltip->{'equipData'}->{'subclassName'}; }
 * 1) Parse Type, Slot, and Bag ###

if(defined($item_tooltip->{'equipData'}->{'inventoryType'})) {		if($item_tooltip->{'equipData'}->{'inventoryType'} eq "18") {			$tooltip{'bag'} = $item_tooltip->{'equipData'}->{'containerSlots'}; }		elsif($item_tooltip->{'equipData'}->{'inventoryType'} ne "0") {			if($item_tooltip->{'classId'} eq "6") {				$tooltip{'slot'} = "Projectile"; }			else {				$tooltip{'slot'} = $slots[$item_tooltip->{'equipData'}->{'inventoryType'}]; }		}	}

### Weapon ### if($item_tooltip->{'classId'} eq "2") {		push(@categories, $weapon_plural{$tooltip{'type'}}); }

### Armor ### if($item_tooltip->{'classId'} eq "4") {		push(@categories, $tooltip{'type'} . " Armor"); push(@categories, "Armor:" . $tooltip{'slot'}); } } verbose("Speed & Dmg & DmgType & Bonus & BonusType & DPS"); if(defined($item_tooltip->{'damageData'})) {	if(defined($item_tooltip->{'damageData'}->{'speed'})) {		$tooltip{'speed'} = $item_tooltip->{'damageData'}->{'speed'}; }
 * 1) Parse Speed, Dmg, DmgType, Bonus, BonusType, and DPS ###

if(defined($item_tooltip->{'damageData'}->{'damage'})) {		$tooltip{'dmg'} = $item_tooltip->{'damageData'}->{'damage'}->{'min'}. " - " . $item_tooltip->{'damageData'}->{'damage'}->{'max'}; $tooltip{'dmgtype'} = $dmgtype[$item_tooltip->{'damageData'}->{'damage'}->{'type'}]; }

if(defined($item_tooltip->{'damageData'}->{'dps'})) {		$tooltip{'dps'} = $item_tooltip->{'damageData'}->{'dps'}; } }

verbose("Armor"); if(defined($item_tooltip->{'armor'}) && $item_tooltip->{'armor'} > 0) {	$tooltip{'armor'} = $item_tooltip->{'armor'}; }
 * 1) Parse Armor ###

verbose("InstanceBind"); if(defined($item_tooltip->{'instanceBound'})) {	$tooltip{'instancebind'} = $item_tooltip->{'instancebind'}; }
 * 1) Parse InstanceBind ###

verbose("Block"); if(defined($item_tooltip->{'blockValue'}) && $item_tooltip->{'blockValue'} > 0) {	$tooltip{'block'} = $item_tooltip->{'blockValue'}; }
 * 1) Parse Block ###

verbose("Attrib"); my $attribs = ""; foreach $attribute (@attributes) {	if(defined($item_tooltip->{"$attribute"})) {		my $modifier = ""; if($item_tooltip->{"$attribute"} > 0) {			$modifier = "+"; }
 * 1) Parse Attrib ###

if($attribs ne "") {			$attribs .= " "; }		$attribs .= "$modifier". $item_tooltip->{"$attribute"}. " " . $attributes_hash{$attribute} . ""; } }

if($attribs ne "") {	$tooltip{'attrib'} = $attribs; }

verbose("Req");
 * 1) Parse Req ###
 * 1) Need Example ###

verbose("Sockets & Sockbonus"); if(defined($item_tooltip->{'socketData'})) {	push(@categories, "Socketed Items");
 * 1) Parse Sockets and Sockbonus ###

if(defined($item_tooltip->{'socketData'}->{'socketMatchEnchant'})) {		$tooltip{'sockbonus'} = $item_tooltip->{'socketData'}->{'socketMatchEnchant'}; }

my $sockets = ""; my $socket_ref = scalar($item_tooltip->{'socketData'}->{'socket'}); my @sockets_arr = @$socket_ref;

foreach $socket (@sockets_arr) {		if($sockets ne "") {			$sockets .= " "; }		$sockets .= ""; }	$tooltip{'sockets'} = $sockets; } verbose("Durability"); if(defined($item_tooltip->{'durability'})) {	$tooltip{'durability'} = $item_tooltip->{'durability'}->{'max'}; }
 * 1) Parse Durability ###

verbose("Locked");
 * 1) Parse Locked ###
 * 1) Not Stored in Sources ###

verbose("Races"); if(defined($item_tooltip->{'allowableRaces'})) {	if(ref($item_tooltip->{'allowableRaces'}->{'race'}) == "ARRAY") {		my $races = ""; my $race_ref = scalar($item_tooltip->{'allowableRaces'}->{'race'}); my @race_arr = @$race_ref; foreach $race (@race_arr) {			if($races ne "") {				$races .= ", "; }			$races .= $race; }		$tooltip{'races'} = $races; }	else {		$tooltip{'races'} = $item_tooltip->{'allowableRaces'}->{'race'}; } } verbose("Classes"); if(defined($item_tooltip->{'allowableClasses'})) {	if(ref($item_tooltip->{'allowableClasses'}->{'class'}) == "ARRAY") {		my $classes = ""; my $class_ref = scalar($item_tooltip->{'allowableClasses'}->{'sclass'}); my @class_arr = @$class_ref;
 * 1) Parse Races ###
 * 1) Parse Classes ###

foreach $class (@class_arr) {			if($classes ne "") {				$classes .= ", "; }			$classes .= $class; }		$tooltip{'classes'} = $classes; }	else {		$tooltip{'classes'} = $item_tooltip->{'allowableClasses'}->{'class'}; } }

verbose("Rep & RFaction"); if(defined($item_tooltip->{'requiredFaction'})) {	$tooltip{'rep'} = $reputation[$item_tooltip->{'requiredFaction'}->{'rep'}]; $tooltip{'rfaction'} = $item_tooltip->{'requiredFaction'}->{'name'}; }
 * 1) Parse Rep and RFaction ###

verbose("Skill"); if(defined($item_tooltip->{'requiredAbility'})) {	$tooltip{'skill'} = $item_tooltip->{'requiredAbility'}; }
 * 1) Parse Skill ###

verbose("Level"); if(defined($item_tooltip->{'requiredLevel'}) && $item_tooltip->{'requiredLevel'} ne "1") {	$tooltip{'level'} = $item_tooltip->{'requiredLevel'}; }
 * 1) Parse Level ###

if(defined($ii_item->{'plansFor'})) {	$tooltip{'create'} = $ii_item->{'plansFor'}->{'spell'}->{'item'}->{'name'}; $tooltip{'createeq'} = $quality[$ii_item->{'plansFor'}->{'spell'}->{'item'}->{'quality'}];
 * 1) Parse Create, CreateEQ, and Mats ###

if(defined($ii_item->{'plansFor'}->{'spell'}->{'reagent'}->{'name'})) {		$tooltip{'mats'} = "" . $ii_item->{'plansFor'}->{'spell'}->{'reagent'}->{'name'} . " (" . $ii_item->{'plansFor'}->{'spell'}->{'reagent'}->{'count'} . ")"; }	else {		my $mats = ""; my $reagent_ref = scalar($ii_item->{'plansFor'}->{'spell'}->{'reagent'}); my %reagent_hash = %$reagent_ref; my @reagent_keys = keys(%reagent_hash); foreach $reagent (@reagent_keys) {			if($mats ne "") {				$mats .= ", "; }			$mats .= "$reagent (" . $reagent_hash{$reagent}->{'count'} . ")"; }		$tooltip{'mats'} = $mats; }

my $requiredSkill = $ii_item->{'requiredSkill'}; if($requiredSkill eq "Alchemy") {		push(@categories, "Alchemy Recipe"); }	elsif($requiredSkill eq "Blacksmithing") {		push(@categories, "Blacksmithing Plans"); }	elsif($requiredSkill eq "Enchanting") {		push(@categories, "Enchanting Recipes"); }	elsif($requiredSkill eq "Leatherworking") {		push(@categories, "Leatherworking Patterns"); }	elsif($requiredSkill eq "Tailoring") {		push(@categories, "Tailoring Patterns"); }	elsif($requiredSkill eq "Jewelcrafting") {		push(@categories, "Jewelcrafting Designs"); }	elsif($requiredSkill eq "Engineering") {		push(@categories, "Engineering Schematics"); }	elsif($requiredSkill eq "Fishing") {		push(@categories, "Fishing"); }	elsif($requiredSkill eq "First Aid") {		push(@categories, "First Aid"); }	elsif($requiredSkill eq "Cooking") {		push(@categories, "Cooking"); } }

verbose("Effect & Create & CreateEQ & Mats"); if(defined($item_tooltip->{'spellData'})) {	if(ref($item_tooltip->{'spellData'}->{'spell'}) eq "ARRAY") {		my $effects = ""; my $effect_ref = scalar($item_tooltip->{'spellData'}->{'spell'}); my @effect_arr = @$effect_ref;
 * 1) Parse Effect ###

foreach $effect (@effect_arr) {			if($effects ne "") {				$effects .= " "; }			$effects .= $triggers[$effect->{'trigger'}]. ": " . $effect->{'desc'};

if(defined($effect->{'charges'})) {				$tooltip->{'charge'} = $effect->{'charges'}; }		}

$tooltip{'effect'} = $effects; }	else {		$tooltip{'effect'} = $triggers[$item_tooltip->{'spellData'}->{'spell'}->{'trigger'}]. ": " . $item_tooltip->{'spellData'}->{'spell'}->{'desc'};

if(defined($item_tooltip->{'spellData'}->{'spell'}->{'charges'})) {			$tooltip->{'charge'} = $item_tooltip->{'spellData'}->{'spell'}->{'charges'}; }	} }

verbose("Comment"); if(defined($item_tooltip->{'desc'})) {	$tooltip{'comment'} = $item_tooltip->{'desc'}; }
 * 1) Parse Comment ###

verbose("Desc");
 * 1) Parse Desc ###
 * 1) Need Example ###

verbose("Cooldown");
 * 1) Parse Cooldown ###
 * 1) Not Stored in Sources ###

verbose("Cast");
 * 1) Parse Cast ###
 * 1) Not Stored in Sources ###

verbose("ILvl"); if(defined($ii_item->{'level'})) {	$tooltip{'ilvl'} = $ii_item->{'level'}; }
 * 1) Parse ILvl ###

verbose("Source"); if(defined($ii_item->{'createdBy'})) {	$tooltip{'source'} = "Created"; $sources{'createdBy'} =	"Created by " . $ii_item->{'createdBy'}->{'spell'}->{'item'}->{'name'} . "";
 * 1) Parse Source ###

my $requiredSkill = $ii_item->{'createdBy'}->{'spell'}->{'item'}->{'requiredSkill'}; if($requiredSkill eq "Alchemy") {		push(@categories, "Alchemy Products"); if($tooltip{'name'} =~ /Potion/) {			push(@categories, "Potions"); }	}	elsif($requiredSkill eq "Blacksmithing") {		push(@categories, "Blacksmithing Products"); }	elsif($requiredSkill eq "Enchanting") {		push(@categories, "Enchanting Products"); }	elsif($requiredSkill eq "Leatherworking") {		push(@categories, "Leatherworking Products"); }	elsif($requiredSkill eq "Tailoring") {		push(@categories, "Tailoring Products"); }	elsif($requiredSkill eq "Jewelcrafting") {		push(@categories, "Jewelcrafting Products"); }	elsif($requiredSkill eq "Engineering") {		push(@categories, "Engineering Products"); }	elsif($requiredSkill eq "First Aid") {		push(@categories, "First Aid Products") }	elsif($requiredSkill eq "Cooking") {		push(@categories, "Cooking Products"); } }

if(defined($ii_item->{'dropCreatures'})) {	$tooltip{'source'} = "Drop"; if(defined($ii_item->{'dropCreatures'}->{'creature'}->{'id'})) {		my $level; if($ii_item->{'dropCreatures'}->{'creature'}->{'minLevel'} == $ii_item->{'dropCreatures'}->{'creature'}->{'maxLevel'}) {			$level = $ii_item->{'dropCreatures'}->{'creature'}->{'maxLevel'}; }		else {			$level = $ii_item->{'dropCreatures'}->{'creature'}->{'minLevel'}. " - " . $ii_item->{'dropCreatures'}->{'creature'}->{'maxLevel'}; }

if($ii_item->{'dropCreatures'}->{'creature'}->{'classification'} ne "0") {			$level .= " ". $classification[$ii_item->{'dropCreatures'}->{'creature'}->{'classification'}]; }

my $area = $ii_item->{'dropCreatures'}->{'creature'}->{'area'}; $area =~ s/^The //g; $area =~ s/-/ /g;

my $heroic = ""; if(defined($ii_item->{'dropCreatures'}->{'creature'}->{'heroic'})) {			$heroic = " (Heroic)"; }

$sources{'dropCreatures'} = "Dropped by Level $level " . $ii_item->{'dropCreatures'}->{'creature'}->{'name'} . " - $area$heroic - ". $dropRate[$ii_item->{'dropCreatures'}->{'creature'}->{'dropRate'}]. " \n"; $category_areas{$area} = 1;

}	else {		my $creatures = "Dropped by: \n"; my $creatures_ref = scalar($ii_item->{'dropCreatures'}->{'creature'}); my %creatures_hash = %$creatures_ref; my @creatures_keys = sort {$creatures_hash{$a}->{'area'} cmp $creatures_hash{$b}->{'area'} || $a cmp $b} keys(%creatures_hash); foreach $creature (@creatures_keys) {				my $level; if($creatures_hash{$creature}->{'minLevel'} == $creatures_hash{$creature}->{'maxLevel'}) {				$level = $creatures_hash{$creature}->{'maxLevel'}; }			else {				$level = $creatures_hash{$creature}->{'minLevel'}. " - " . $creatures_hash{$creature}->{'maxLevel'}; }

if($creatures_hash{$creature}->{'classification'} ne "0") {			$level .= " ". $classification[$creatures_hash{$creature}->{'classification'}]; }

my $area = $creatures_hash{$creature}->{'area'}; $area =~ s/^The //g; $area =~ s/-/ /g;

my $heroic = ""; if(defined($creatures_hash{$creature}->{'heroic'})) {				$heroic = " (Heroic)"; }

$creatures .= "Level $level $creature - $area$heroic - ". $dropRate[$creatures_hash{$creature}->{'dropRate'}]. " \n"; $category_areas{$area} = 1; }		$sources{'dropCreatures'} = $creatures; } }

if(defined($ii_item->{'rewardFromQuests'})) {	$tooltip{'source'} = "Quest"; push(@categories, "Quest Rewards");

if(defined($ii_item->{'rewardFromQuests'}->{'quest'}->{'name'})) {		$sources{'rewardFromQuests'} = "Quest Reward From \n"; }	else {		my $quests = "Quest Reward From: \n"; my $quests_ref = scalar($ii_item->{'rewardFromQuests'}->{'quest'}); my %quests_hash = %$quests_ref; my @quests_keys = keys(%quests_hash); foreach $quest (@quests_keys) {					$quests .= " \n"; }		$sources{'rewardFromQuests'} = $quests; } }

if(defined($ii_item->{'vendors'})) {	$tooltip{'source'} = "Vendor"; if(defined($ii_item->{'vendors'}->{'creature'}->{'name'})) {		$sources{'vendor'} = "Sold by " . $ii_item->{'vendors'}->{'creature'}->{'name'} . " in " . $ii_item->{'vendors'}->{'creature'}->{'area'} . " \n"; }	else {		my $vendors = "Sold by: \n"; my $vendors_ref = scalar($ii_item->{'vendors'}->{'creature'}); my %vendors_hash = %$vendors_ref; my @vendors_keys = keys(%vendors_hash); foreach $vendor (@vendors_keys) {					$vendors .= "$vendor in " . $vendors_hash{$vendor}->{'area'} . " \n"; }		$sources{'vendor'} = $vendors; } }

verbose("Disenchant"); if(defined($ii_item->{'disenchantLoot'})) {	if(defined($ii_item->{'disenchantLoot'}->{'item'}->{'icon'})) {		my $count = "1";
 * 1) Parse Disenchant ###

if($ii_item->{'disenchantLoot'}->{'item'}->{'minCount'} == $ii_item->{'disenchantLoot'}->{'item'}->{'maxCount'}) {			$count = $ii_item->{'disenchantLoot'}->{'item'}->{'maxCount'}; }		else {			$count = $ii_item->{'disenchantLoot'}->{'item'}->{'minCount'}. " - " . $ii_item->{'disenchantLoot'}->{'item'}->{'maxCount'}; }

$disenchant = "Requires Level ". $ii_item->{'disenchantLoot'}->{'requiredSkillRank'}. " Enchanting \n"; $disenchant .= "$count". "x (" . $dropRate[$ii_item->{'disenchantLoot'}->{'item'}->{'dropRate'}] . ") \n"; }	else {		my $items = ""; my $items_ref = scalar($ii_item->{'disenchantLoot'}->{'item'}); my %items_hash = %$items_ref; my @items_keys = keys(%items_hash); foreach $item (@items_keys) {			my $count = "1";

if($items_hash{$item}->{'minCount'} == $items_hash{$item}->{'maxCount'}) {				$count = $items_hash{$item}->{'maxCount'}; }			else {				$count = $items_hash{$item}->{'minCount'}. " - " . $items_hash{$item}->{'maxCount'}; }			$items .= "$count". "x (" . $dropRate[$items_hash{$item}->{'dropRate'}] . ") \n"; }

$disenchant = "Requires Level ". $ii_item->{'disenchantLoot'}->{'requiredSkillRank'}. " Enchanting \n$items"; } }

verbose("Sell");
 * 1) Parse Sell ###
 * 1) Not Stored in Sources ###

verbose("Sell & Vendor"); if(defined($ii_item->{'cost'})) {	if(defined($ii_item->{'cost'}->{'token'})) {		my $token_item = item_lookup($ii_item->{'cost'}->{'token'}->{'id'}); my $token = $token_item->{'name'}; $tooltip{'vendor'} = $ii_item->{'cost'}->{'token'}->{'count'}. "x$token"; }
 * 1) Parse Sell and Vendor ###

if(defined($ii_item->{'cost'}->{'sellPrice'})) {		my @sp = split(//, $ii_item->{'cost'}->{'sellPrice'}); my $temp = pop(@sp); my $copper = pop(@sp). $temp; my $temp = pop(@sp); my $silver = pop(@sp). $temp; my $gold = join(//, @sp); if(!defined($gold)) {			$gold = "0"; }		if(!defined($silver)) {			$silver = "0"; }		if(!defined($copper)) {			$copper = "0"; }		$tooltip{'sell'} = ""; }

if(defined($ii_item->{'cost'}->{'buyPrice'})) {		my @sp = split(//, $ii_item->{'cost'}->{'buyPrice'}); my $temp = pop(@sp); my $copper = pop(@sp). $temp; my $temp = pop(@sp); my $silver = pop(@sp). $temp; my $gold = join(//, @sp); if(!defined($gold)) {			$gold = "0"; }		if(!defined($silver)) {			$silver = "0"; }		if(!defined($copper)) {			$copper = "0"; }		$tooltip{'vendor'} = ""; } }

if(scalar(keys(%category_areas)) > 0) {	my @category_area_keys = sort{$a cmp $b} keys(%category_areas); foreach $area (@category_area_keys) {		push(@categories, "Instance:$area"); } }
 * 1) Categories ###
 * 2) Instance ###

print(" \n\n");
 * 1) Output Results ###
 * 2) Print Header ###

print("\n\n"); print(" \n"); print("==Source==\n"); if(defined($sources{'createdBy'})) {	print($sources{'createdBy'} . "\n"); }
 * 1) Print Tooltip ###
 * 1) Print Source ###

if(defined($sources{'rewardFromQuests'})) {	print($sources{'rewardFromQuests'} . "\n"); }

if(defined($sources{'dropCreatures'})) {	print($sources{'dropCreatures'} . "\n"); }

if(defined($sources{'vendor'})) {	print($sources{'vendor'} . "\n"); }

print("\n");

if($disenchant ne "") {	print("==Disenchants into==\n$disenchant\n\n"); }
 * 1) Print Disenchant ###

print("==External links==\n"); print("\n\n");
 * 1) Print External links ###

foreach $category (@categories) {	print("\n"); }
 * 1) Print Categories ###

print(" \n");

sub verbose {	my $message = shift(@_); if(defined($verbose)) {		print(STDERR "# $message\n"); } }

sub item_lookup {	my $id = shift(@_); my $item_url = "http://armory.worldofwarcraft.com/item-tooltip.xml?i=$id"; my $item_response = $browser->get($item_url,		'Accept' => 'text/xml,application/xml,application/xhtml+xml;q=0.9,text/plain',		'Accept-Language' => 'en-us;q=0.5',		'Accept-Charset' => 'ISO-8559-1,utf-8;q=0.7,*;q=0.7',		'User-Agent' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4'	);

my $item_content = $item_response->content; my $item_data = $xml->XMLin($item_content, 'SuppressEmpty' => undef); my $item = $item_data->{'itemTooltips'}->{'itemTooltip'}; return $item; }