Solved

How can I parse the Perl output?

Posted on 2011-03-01
2
478 Views
Last Modified: 2012-05-11
I have a followup question on this issue:

In my PERL code the following line :

print Dumper $ssc->{'myStates'};

Open in new window


returns:
      
$VAR1 = [
          bless( {
                   'priority' => 'Unset',
                   'owner' => 'Unassigned',
                   'required' => 'ABCD',
                   'status' => 'Completed',
                 }, 'gState' )
        ];

Open in new window



How can I extract the 'status' from this output in Perl?

Thanks,
      
0
Comment
Question by:Tolgar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 26

Accepted Solution

by:
wilcoxon earned 500 total points
ID: 35012851
print $ssc->{myStates}[0]{status};

If you have more than one instance of gState, you'll need to loop over the items (or something similar) to get all of the status.
0
 
LVL 26

Expert Comment

by:wilcoxon
ID: 35012875
To further explain what you are looking at...

$VAR1 in the output corresponds to $ssc->{myStates} since that's what you called Dumper with.
The [] around it indicates that it is an array reference (needing [0] to get the first item).
The bless({},'gState') says that it is a blessed hash which should be irrelevant for extracting data so {state} will get us the value of state.

So we end up with $ssc->{myStates}[0]{status}.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question