View Single Post
  #1  
Old 10-15-2005, 08:10 PM
donger donger is offline
Junior Member
 
Join Date: Apr 2004
Posts: 5
Default a little perl help, please

Hi,
I'm working on fixing the bisonbison converter so that it works with the new absolute hand history format. Right now, everything is working except you have to reorder the seat numbers numerically before pasting in the hand:

Seat 6 - DAWGNWNUTS69 ($196 in chips)
Seat 7 - JERKSTORE ($181.50 in chips)
Seat 9 - NEOND ($104 in chips)
Seat 5 - STANSFIELD ($49 in chips)

has to become:

Seat 5 - STANSFIELD ($49 in chips)
Seat 6 - DAWGNWNUTS69 ($196 in chips)
Seat 7 - JERKSTORE ($181.50 in chips)
Seat 9 - NEOND ($104 in chips)

in order for the converter to work.

I was wondering if someone could help me write the piece of code to sort this $Players object by the PlayerSeatNumber property?

Here's the relevant code where the object is filled:

<font class="small">Code:</font><hr /><pre>
while ($Message =~ s/Seat (\d+) - (.*?) \(((\$)?\d+(\.\d+)?) in chips\)//)
{
$Players{"$j"}-&gt;{"PlayerSeatNumber"} = $1;
$Players{"$j"}-&gt;{"PlayerName"} = $2;
$Players{"$j"}-&gt;{"PlayerStack"} = $3;

###SORT $Players here so the following code doesn't break

#name the seats, starting at the button
if ($Players{"$j"}-&gt;{"PlayerSeatNumber"} == $SeatButton)
{
$Players{"$j"}-&gt;{"PlayerTitle"} = "Button";
$Players{"$j"}-&gt;{"PlayerTitleDisplay"} = "Button";
}
elsif (($Players{"$j"}-&gt;{"PlayerSeatNumber"} &gt; $SeatButton) &amp;&amp; ($j &lt;= $PlayerCount))
{
$Players{"$j"}-&gt;{"PlayerTitle"} = pop @SeatTitleList;
$Players{"$j"}-&gt;{"PlayerTitleDisplay"} = pop @SeatTitleDisplayList;

}
$j++;
}
</pre><hr />



THANKS!
donger
Reply With Quote