perlPractioner has asked for the wisdom of the Perl Monks concerning the following question:
Hi Monks, this post is in reference to one of my previous posts from last week here. Since I only have a chance to work on this over the weekends, my repsonse is a bit delayed. I am using JIRA::Client to retrieve the issues from a JIRA filter. The issues are returned as a blessed hash resembling the following:
$VAR1=bless( { 'priority' => '2', 'customFieldValues' => [ bless( { 'customfieldID' => 'cus +tomfield_12345', 'values' => ['John Smit +h'], 'key' => undef}, 'RemoteCustomFieldValue +' ), bless( { 'customfieldID' => 'cus +tomfield_abcde', 'values' => ['Californi +a'], 'key' => undef}, 'RemoteCustomFieldValue +' )], 'status' => 'Completed' }, 'RemoteIssue'); $VAR1=bless( { 'priority' => '2', 'customFieldValues' => [ bless( { 'customfieldID' => 'cus +tomfield_12345', 'values' => ['Mary Monr +oe], 'key' => undef}, 'RemoteCustomFieldValue +' ), bless( { 'customfieldID' => 'cus +tomfield_abcde', 'values' => ['New York' +], 'key' => undef}, 'RemoteCustomFieldValue +' )], 'status' => 'In progress' }, 'RemoteIssue');
Each issue is returned as $VAR1 with priority set to '2'. Within each issue, there are custom fields ('RemoteCustomFieldValue') such as the client's name and their state. I know the customfieldIDs that reference each name and state. There is also a non-custom field ('RemoteIssue') such as the issue status. I am not too familiar with iterating through hashes/sub-hashes, but for every $VAR1 in this hash, I need the 'values' of each customfieldId (which I already know). So for example, to get the client's name for each issue, I need to get the value where customfieldId is 'customfield_12345'. Also, for each issue I am trying to get the status, which is a 'RemoteIssue' and not a 'RemoteCustomFieldIssue'. From this hash, I am trying to create a table which looks like this:
| Name | State | Status |
|---|---|---|
| John Smith | California | Completed |
| Mary Monroe | New York | In Progress |
The code I have so far that generates the blessed hash from above is shown below. Any suggestions would greatly be appreciated. Thanks in advance monks.
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use LWP::UserAgent; use JIRA::Client; use SOAP::Lite; my $user = 'username'; my $pw = 'password'; my $filterID = '12345'; my $jira=JIRA::Client->new('http://example.com/jira',$user,$pw); $jira->set_filter_iterator('$filterID'); while (my $issue = $jira->next_issue()) { my $value = Dumper($issue); print $value; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: JIRA::Client returns blessed hash
by keszler (Priest) on Dec 10, 2011 at 17:46 UTC | |
by perlPractioner (Novice) on Dec 10, 2011 at 17:56 UTC | |
by keszler (Priest) on Dec 10, 2011 at 18:33 UTC | |
by perlPractioner (Novice) on Dec 10, 2011 at 19:23 UTC | |
by keszler (Priest) on Dec 10, 2011 at 19:46 UTC | |
|