Update: OOPS! The solution in this post will show you all the values, but will not allow you to change them. See my reply to this post for a more appropriate solution.
Well, you could do
my $iter = get_value_iter($oWkBook);
while ($iter->(my $item)) {
print("$item\n");
}
if you defined get_value_iter as follows:
sub get_value_iter {
my @values = @_;
my $sub_iter;
return sub {
our $rv; local *rv = \$_[0];
for (;;) {
if ($sub_iter) {
if ($sub_iter->($rv)) {
return 1;
}
undef $sub_iter;
}
return if not @values;
$rv = shift(@values);
while (ref($rv) eq 'SCALAR') {
$rv = $$rv;
}
if (ref($rv) eq 'ARRAY') {
$sub_iter = get_value_iter(@$rv);
next;
}
if (ref($rv) eq 'HASH') {
$sub_iter = get_value_iter(values %$rv);
next;
}
return 1;
}
};
}
Scalar::Util's reftype can be used instead of ref if you wish to traverse objects.
-
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.
|