A gentleman I know wrote some code to parse a file and then feed the values into a hash. I seem to be retarded with perl hash. Could someone give me an example of pulling data from this? Here is his documentation: EDIT: i updated with his full pm
package AuctioneerParse; # AuctioneerParse v2.1 - Perl Module to Parse Auctioneer LUA Data File +s # Copyright 2005, 2006 Christopher J. Carlson <c@rlson.net>. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. # # Changelog # ------------------------------- # # v2.1 - Fixed Realms that have spaces or apostrophes in their name # # v2.0 - Initial Rewrite # # Formats Explained (data Section) # -------------------------------- # ["9968:1201:0"] = "6:6:120210:0:0:6:167800|20000x2:26000:31600:33600 +:36600", # -------------------------------------------------------------------- +-------- # # 9968 = Item ID (ie Wool Cap) # 1201 = Random ID (ie of the Bear) # 0 = Enchant ID (ids any Enchants or Armor Kits Applied) # -------- # # 6 = Count # 6 = Minimum Count # 120210 = Minimum Price # 0 = Bid Count # 0 = Bid Price # 6 = Buy Count # 167800 = Total Price # -------- # # 20000x2 = A 2 Stack for 20000 # 31600 = A 1 Stack for 31600 # 33600 = A 1 Stack for 33600 # 33600 = A 1 Stack for 36600 # -------- # # Note on Prices: # 36600 = 3 Gold, 66 Silver, and 00 Bronze. Break it up. # # -------------------------------------------------------------------- +-------- # # # Returned Hash Format: # # {14260:771:0} = { # 'allPrices' => [ # 8900, # 22000 # ], # 'itemMetrics' => '2:2:20100:0:0:2:30900', # 'bidCount' => '0', # 'minPrice' => '20100', # 'itemClass' => '2', # 'buyPrice' => '30900', # 'buyCount' => '2', # 'numCount' => '2', # 'minCount' => '2', # 'itemName' => 'Bloodwoven Bracers of the Owl', # 'itemPrices' => '8900:22000', # 'bidPrice' => '0', # 'randomID' => '771', # 'baseNum' => '14260', # 'mean' => '400', # 'median' => '300', # 'mode' => '400', # 'stdDev' => '100' # } # -------------------------------------------------------------------- +-------- # use strict; use Statistics::Descriptive; my $DEBUG = 0; sub new { my ($class, %args) = @_; my $self = bless {}, ref($class) || $class; return $self; } sub loadFile { my $self = shift; my $file = shift; open (DATA, "$file") || die ("Can't Find File ($file): $!\n"); my $LUAHash; my $depth = 0; my @obj; while (<DATA>) { chomp; if (m/\["?([A-Za-z0-9\-\' ]+)"?\] = {/) { push @obj, $1; print "[$depth] Adding $1 (@obj)\n" if $DEBUG; $depth++; next; } if (m/},$/) { my $a = pop @obj; print "[$depth] Removing: $a (@obj)\n" if $DEBUG; $depth--; next; } s/^\s+//; my ($key, $value) = split / = /; $key =~ s/(\["|"\])//g; $value =~ s/("|,)//g; if (scalar(@obj) == 3) { $LUAHash->{$obj[0]}->{$obj[1]}->{$obj[2]}->{$key} = $value +; } if (scalar(@obj) == 2) { $LUAHash->{$obj[0]}->{$obj[1]}->{$key} = $value; } if (scalar(@obj) == 1) { $LUAHash->{$obj[0]}->{$key} = $value; } } if ($depth != 0) { print STDERR "Warning: Corrupted Auctioneer.lua File Detected. +\n"; } return $LUAHash; } sub loadItems { my $self = shift; my $luaHASH = shift; my $itemHash; foreach my $RealmFaction (keys %{$luaHASH->{data}}) { foreach my $item (keys %{$luaHASH->{data}->{$RealmFaction}}) { my $itemNum = $item; my $itemData = $luaHASH->{data}->{$RealmFaction}->{$item}; my ($baseNum, $randomID, $enchantID) = split /:/, $itemNum +; my ($itemMetrics, $itemPrices) = split(/\|/, $itemData); my @Metrics = split /:/, $itemMetrics; my @uniformPrices; my @Prices = split /:/, $itemPrices; foreach my $price (@Prices) { if ($price =~ m/x\d+/) { my ($entityPrice, $entityCount) = split /x/,$price +; for (1..$entityCount) { push @uniformPrices, $entityPrice; } } else { push @uniformPrices, $price; } } $itemHash->{$RealmFaction}->{$itemNum}->{allPrices} = [ @u +niformPrices ]; my $stat = Statistics::Descriptive::Full->new(); $stat->add_data(@uniformPrices); $itemHash->{$RealmFaction}->{$itemNum}->{mean} = $stat->me +an() || 0; $itemHash->{$RealmFaction}->{$itemNum}->{stdDev} = $stat-> +standard_deviation() || "0"; $itemHash->{$RealmFaction}->{$itemNum}->{median} = $stat-> +median() || 0; $itemHash->{$RealmFaction}->{$itemNum}->{mode} = $stat->mo +de() || 0; $itemHash->{$RealmFaction}->{$itemNum}->{itemMetrics} = $i +temMetrics; $itemHash->{$RealmFaction}->{$itemNum}->{itemPrices} = $it +emPrices; $itemHash->{$RealmFaction}->{$itemNum}->{numCount} = $Metr +ics[0]; $itemHash->{$RealmFaction}->{$itemNum}->{minCount} = $Metr +ics[1]; $itemHash->{$RealmFaction}->{$itemNum}->{minPrice} = $Metr +ics[2]; $itemHash->{$RealmFaction}->{$itemNum}->{bidCount} = $Metr +ics[3]; $itemHash->{$RealmFaction}->{$itemNum}->{bidPrice} = $Metr +ics[4]; $itemHash->{$RealmFaction}->{$itemNum}->{buyCount} = $Metr +ics[5]; $itemHash->{$RealmFaction}->{$itemNum}->{buyPrice} = $Metr +ics[6]; $itemHash->{$RealmFaction}->{$itemNum}->{baseNum} = $baseN +um; $itemHash->{$RealmFaction}->{$itemNum}->{randomID} = $rand +omID; $itemHash->{$RealmFaction}->{$itemNum}->{enchantID} = $enc +hantID; } foreach my $itemNum (keys %{$luaHASH->{info}}) { my $itemData = $luaHASH->{info}->{$itemNum}; my ($itemClass, $itemName) = split /\|/, $itemData; if (exists($itemHash->{$RealmFaction}->{$itemNum})) { $itemHash->{$RealmFaction}->{$itemNum}->{itemName} = $ +itemName; $itemHash->{$RealmFaction}->{$itemNum}->{itemClass} = +$itemClass; } } } return $itemHash; } 1;

Edit: g0n - readmore tags


In reply to some help w/ hashes by rael438

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.