I have a Tk callback where I give it as arguments an anonymous hash, like so:
$canvas->bind($dk_img, "<Button-1>", [\&frst_clk,
{ deck => $deck, waste => $waste, img => $dk_img }]);
Well, after some experimentation, I realized the placement of how I get at the arguments is VERY important (i.e., if I don't shift the first arg off--an implicit Tk object, in this case a canvas--getting at the other one is a mess).
However, even after this, I cannot seem to get at the other argument. I'm getting unitialized errors, so I 'Data::Dumped' it, resulting in this:
$VAR1 = {
'deck' => bless( {
'next' => 0,
'num' => 0,
'max' => 52,
'cards' => [
bless( {
'state' => 'up',
'where' => $VAR1->{
+'deck'},
'value' => 'j',
'suit' => 's'
}, 'Card' ),
...more blessed cards...
bless( {
'state' => 'down',
'where' => $VAR1->{
+'deck'},
'value' => 5,
'suit' => 'c'
}, 'Card' )
]
}, 'Pile' ),
'img' => 12,
'waste' => bless( {
'next' => 0,
'num' => 0,
'max' => 52
}, 'Pile' )
};
Well, I know I have what I want, so its a tricky matter of dereferencing, or what not. I figured it was an anonymous array, so I tried:
$_->{deck}
## to no avail, so then I tried:
$_{deck}
## then:
${@_{deck}}
## and a bunch of other big and baggy monsters ...
How do I get at the data?
(incidentally, this is the result of a rewrite of some code I posted before about a solitaire program, viewable on my sketch pad...soon)
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.